本文整理了Java中org.apache.isis.core.metamodel.adapter.version.Version
类的一些代码示例,展示了Version
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version
类的具体详情如下:
包路径:org.apache.isis.core.metamodel.adapter.version.Version
类名称:Version
[英]An instance of this class is held by each ObjectAdapter and is used to represent a particular version (at a point in time) of domain object wrapped by that adapter.
This is normally done using some form of incrementing number or timestamp, which would be held within the implementing class. The numbers, timestamps, etc should change for each changed object, and the different() method should indicate that the two Version objects are different.
The user's name and a timestamp should alos be kept so that when an message is passed to the user it can be of the form "user has change object at time"
[中]此类的一个实例由每个ObjectAdapter持有,用于表示由该适配器包装的域对象的特定版本(在某个时间点)。
这通常是使用某种形式的递增数字或时间戳来完成的,它将保存在实现类中。每个更改的对象的数字、时间戳等都应该更改,而different()方法应该指示两个版本对象是不同的。
应该保留用户名和时间戳,这样当消息传递给用户时,它可以是“用户在时间上有更改对象”的形式
代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime
private boolean shouldSetVersion(final Version version) {
return this.version == null || version == null || version.different(this.version);
}
代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime
public ConcurrencyException(final ObjectAdapter object, final Version updated) {
this(object.getVersion().getUser() + " changed " + object.titleString() + " at " + DateFormat.getDateTimeInstance().format(object.getVersion().getTime()) + "\n\n" + object.getVersion() + " ~ " + updated + "", object.getOid());
}
代码示例来源:origin: org.apache.isis.viewer/scimpi-dispatcher
@Override
public String mapVersion(final Version version) {
// SerialNumberVersion v = (SerialNumberVersion) version;
// return Long.toHexString(v.getSequence());
return version.sequence();
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void whenEqual() throws Exception {
version1 = Version.create(123L);
version2 = Version.create(123L);
assertThat(version1.different(version2), is(false));
}
代码示例来源:origin: org.apache.isis.core/isis-core-plugins-jdo-datanucleus-5
private void allowUnimportantMethodCallsOn(final Version version) {
context.checking(new Expectations() {
{
allowing(version).getSequence();
allowing(version).getUtcTimestamp();
allowing(version).sequence();
allowing(version).getUser();
allowing(version).hasTimestamp();
allowing(version).getTime();
will(returnValue(new Date()));
allowing(mockAuthenticationSession).getUserName();
will(returnValue("fredbloggs"));
}
});
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void sequence_and_toString() throws Exception {
final Version testVersion = new Version(extended);
assertTrue(testVersion.sequence().length() > 0);
assertTrue(testVersion.getSequence() == 0);
assertTrue(testVersion.toString().length() > 0);
assertTrue(testVersion.equals(testVersion));
assertFalse(testVersion.equals(version));
}
代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-impl
public static ResponseBuilder addLastModifiedAndETagIfAvailable(final ResponseBuilder responseBuilder, final Version version) {
if (version != null && version.getTime() != null) {
final Date time = version.getTime();
responseBuilder.lastModified(time);
responseBuilder.tag("" + time);
}
return responseBuilder;
}
代码示例来源:origin: org.apache.isis.viewer/scimpi-dispatcher
final Version adapterVersion = adapter.getVersion();
final Version formVersion = context.getVersion(version);
if (formVersion != null && adapterVersion.different(formVersion)) {
IsisContext.getMessageBroker().addMessage("The " + adapter.getSpecification().getSingularName() + " was edited " + "by another user (" + adapterVersion.getUser() + "). Please make your changes based on their changes.");
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void persistentRootWithVersionAndUserAndTimestamp() {
final String oidStr = "CUS:123^90809:fredbloggs:1231231232";
final RootOid rootOid = oidMarshaller.unmarshal(oidStr, RootOid.class);
assertThat(rootOid.isTransient(), is(false));
assertThat(rootOid.getObjectSpecId(), is(ObjectSpecId.of("CUS")));
assertThat(rootOid.getIdentifier(), is("123"));
assertThat(rootOid.getVersion().getSequence(), is(90809L));
assertThat(rootOid.getVersion().getUser(), is("fredbloggs"));
assertThat(rootOid.getVersion().getUtcTimestamp(), is(1231231232L));
final Oid oid = oidMarshaller.unmarshal(oidStr, Oid.class);
assertThat(oid, equalTo((Oid)rootOid));
}
代码示例来源:origin: org.apache.isis.core/isis-core-objectstore
private synchronized Version nextVersion(final Version version) {
final long sequence = (version != null ? version.getSequence() : 0) + 1;
return SerialNumberVersion.create(sequence, getAuthenticationSession().getUserName(), new Date(Clock.getTime()));
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void persistentRootWithVersionAndUserWithAtSymbol() {
final String oidStr = "CUS:123^90809:fredbloggs@foo.bar:";
final RootOid rootOid = oidMarshaller.unmarshal(oidStr, RootOid.class);
assertThat(rootOid.getVersion().getUser(), is("fredbloggs@foo.bar"));
final Oid oid = oidMarshaller.unmarshal(oidStr, Oid.class);
assertThat(oid, equalTo((Oid)rootOid));
}
代码示例来源:origin: org.apache.isis.core/isis-core-runtime
static Version getVersionIfAny(final Persistable pojo, final AuthenticationSession authenticationSession) {
Object jdoVersion = pojo.dnGetVersion();
if(jdoVersion instanceof Long) {
final Long longVersion = (Long) jdoVersion;
return Version.create(longVersion, authenticationSession.getUserName(), (Date) null);
}
if(jdoVersion instanceof java.sql.Timestamp) {
final Timestamp timestampVersion = (Timestamp) jdoVersion;
return Version.create(timestampVersion.getTime(), authenticationSession.getUserName(), (Date) null);
}
return null;
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void whenNotEqual() throws Exception {
version1 = Version.create(123L);
version2 = Version.create(124L);
assertThat(version1.different(version2), is(true));
}
代码示例来源:origin: org.apache.isis.core/isis-core-viewer-restfulobjects-rendering
public static Response.ResponseBuilder addLastModifiedAndETagIfAvailable(
final Response.ResponseBuilder responseBuilder,
final Version version) {
if (version != null && version.getTime() != null) {
final Date time = version.getTime();
responseBuilder.lastModified(time);
responseBuilder.tag(asETag(time));
}
return responseBuilder;
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void persistentRootWithVersion() {
final String oidStr = "CUS:123^90809::";
final RootOid rootOid = oidMarshaller.unmarshal(oidStr, RootOid.class);
assertThat(rootOid.isTransient(), is(false));
assertThat(rootOid.getObjectSpecId(), is(ObjectSpecId.of("CUS")));
assertThat(rootOid.getIdentifier(), is("123"));
assertThat(rootOid.getVersion().getSequence(), is(90809L));
final Oid oid = oidMarshaller.unmarshal(oidStr, Oid.class);
assertThat(oid, equalTo((Oid)rootOid));
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Override
protected List<Version> getObjectsWithDifferentValue() {
return Arrays.asList(
Version.create(124L, null, (Long)null),
Version.create(125L, null, (Long)null)
);
}
代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime
@Override
public void checkLock(final Version version) {
if (this.version != null && this.version.different(version)) {
LOG.info("concurrency conflict on " + this + " (" + version + ")");
throw new ConcurrencyException(this, version);
}
}
代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-server
public static ResponseBuilder addLastModifiedAndETagIfAvailable(final ResponseBuilder responseBuilder, final Version version) {
if (version != null && version.getTime() != null) {
final Date time = version.getTime();
responseBuilder.lastModified(time);
responseBuilder.tag(asETag(time));
}
return responseBuilder;
}
代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime
protected void toString(final ToString str) {
str.append(resolveState.code());
final Oid oid = getOid();
if (oid != null) {
str.append(":");
str.append(oid.toString());
} else {
str.append(":-");
}
str.setAddComma();
if (getSpecificationNoLoad() == null) {
str.append("class", getObject().getClass().getName());
} else {
str.append("specification", getSpecification().getShortIdentifier());
}
str.append("version", version == null ? null : version.sequence());
}
代码示例来源:origin: org.apache.isis.core/isis-core-metamodel
@Test
public void createWithVersion() throws Exception {
ObjectSpecId objectSpecId = ObjectSpecId.of("CUS");
RootOid oid = RootOid.create(objectSpecId, "123", 456L);
assertThat(oid.getObjectSpecId(), is(objectSpecId));
assertThat(oid.getIdentifier(), is("123"));
assertThat(oid.getVersion().getSequence(), is(456L));
assertThat(oid.isTransient(), is(false));
}
内容来源于网络,如有侵权,请联系作者删除!