Package org.apache.isis.core.metamodel.adapter.version

Examples of org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion


        configuration = new TestProxyConfiguration();
        spec = new TestProxySpecification(this.getClass());
        spec.fields = Collections.emptyList();
        adapter = new TestProxyAdapter();
        adapter.setupSpecification(spec);
        adapter.setOptimisticLock(new SerialNumberVersion(23, null, null));
        adapter.setupOid(SerialOid.createPersistent(1));
        persistenceHelper = new ObjectStorePersistenceHelper(spec);
        transaction = null;
    }
View Full Code Here


    public void save(final ObjectAdapter adapter) {
        pojoByOidMap.put(adapter.getOid(), adapter.getObject());
        titleByOidMap.put(adapter.getOid(), adapter.titleString().toLowerCase());

        final SerialNumberVersion version = versionByOidMap.get(adapter.getOid());
        final SerialNumberVersion nextVersion = nextVersion(version);
        versionByOidMap.put(adapter.getOid(), nextVersion);
        adapter.setOptimisticLock(nextVersion);
    }
View Full Code Here

        adapter.setOptimisticLock(nextVersion);
    }

    private synchronized SerialNumberVersion nextVersion(final SerialNumberVersion version) {
        final long sequence = (version != null ? version.getSequence() : 0) + 1;
        return new SerialNumberVersion(sequence, getAuthenticationSession().getUserName(), new Date(Clock.getTime()));
    }
View Full Code Here

    @Override
    public Version version(final String versionString, final String user, final String timeString) {
        final Long sequence = Long.valueOf(versionString, 16);
        final Long time = Long.valueOf(timeString, 16);
        final Date date = new Date(time);
        return new SerialNumberVersion(sequence, user, date);
    }
View Full Code Here

        return new SerialNumberVersion(sequence, user, date);
    }

    @Override
    public Version newVersion(final String user) {
        return new SerialNumberVersion(1, user, new Date());
    }
View Full Code Here

    @Override
    public Version nextVersion(final Version version) {
        final long sequence = ((SerialNumberVersion) version).getSequence() + 1;
        final String user = version.getUser();
        return new SerialNumberVersion(sequence, user, new Date());
    }
View Full Code Here

    @Test
    public void testname() throws Exception {
        final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(ExampleReferencePojo.class);
        final ObjectAdapter object = IsisContext.getPersistenceSession().createInstance(specification);
        IsisContext.getPersistenceSession().makePersistent(object);
        object.setOptimisticLock(new SerialNumberVersion(3, "username", new Date(1000)));

        final long id = ((SerialOid) object.getOid()).getSerialNo();
        final String key = Long.toString(id, 16);

        final Mockery context = new Mockery();
View Full Code Here

        writer = context.mock(StateWriter.class);
        commandContext = context.mock(NoSqlCommandContext.class);
        keyCreator = context.mock(KeyCreator.class);
        versionCreator = context.mock(VersionCreator.class);

        final Version version = new SerialNumberVersion(2, "username", null);

        context.checking(new Expectations() {
            {
                one(versionCreator).newVersion("tester");
                will(returnValue(version));
View Full Code Here

        final CollectionFacet collectionFacet = field.getFacet(CollectionFacet.class);
        for (final ObjectAdapter element : collectionFacet.iterable(collection)) {
            final StringBuffer insert = new StringBuffer(sql);
            insert.append(values(connector, element));
            final SerialNumberVersion version = new SerialNumberVersion(0, "", new Date());
            insert.append(versionMapping.insertValues(connector, version));
            insert.append(") ");

            connector.insert(insert.toString());
            element.setOptimisticLock(version);
View Full Code Here

    }

    @Override
    public void createObject(final DatabaseConnector connector, final ObjectAdapter object) {
        final int versionSequence = 1;
        final SerialNumberVersion version = createVersion(versionSequence);

        final StringBuffer sql = new StringBuffer();
        sql.append("insert into " + table + " (");
        idMapping.appendColumnNames(sql);
        sql.append(", ");
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.