Package org.openengsb.core.edb.api

Examples of org.openengsb.core.edb.api.EDBCommit


        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("K", "B", data1);
        putValue("Cow", "Milk", data1);
        putValue("Dog", "Food", data1);
        EDBObject v1 = new EDBObject("/test/querynew3", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);

        data1 = new HashMap<String, EDBObjectEntry>();
        putValue("Dog", "Food", data1);
        v1 = new EDBObject("/test/querynew3", data1);
        ci = getEDBCommit();
        ci.update(v1);
        db.commit(ci);

        data1 = new HashMap<String, EDBObjectEntry>();
        putValue("K", "B", data1);
        putValue("Dog", "Food", data1);
        v1 = new EDBObject("/test/querynew4", data1);
        ci = getEDBCommit();
        ci.insert(v1);
        db.commit(ci);

        List<EDBObject> result = db.query(QueryRequest.create());
        EDBObject result1 = getEDBObjectOutOfList(result, "/test/querynew3");
        EDBObject result2 = getEDBObjectOutOfList(result, "/test/querynew4");
View Full Code Here


    public void testQueryOfLastKnownVersion_shouldWork() throws Exception {
        Map<String, EDBObjectEntry> data1v1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1v1);
        putValue("KeyB", "Value A 1", data1v1);
        EDBObject v11 = new EDBObject("/test/object1", data1v1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v11);
        Map<String, EDBObjectEntry> data2v1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 2", data2v1);
        putValue("KeyB", "Value A 1", data2v1);
        EDBObject v12 = new EDBObject("/test/object2", data2v1);
        ci.insert(v12);
        Map<String, EDBObjectEntry> data3v1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 3", data3v1);
        putValue("KeyB", "Value A 1", data3v1);
        EDBObject v13 = new EDBObject("/test/object3", data3v1);
        ci.insert(v13);

        long time1 = db.commit(ci);

        ci = getEDBCommit();
        Map<String, EDBObjectEntry> data1v2 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1v2);
        putValue("KeyB", "Value A 1", data1v2);
        EDBObject v21 = new EDBObject("/test/object1", data1v2);
        ci.update(v21);
        Map<String, EDBObjectEntry> data2v2 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 2", data2v2);
        putValue("KeyB", "Value A 1", data2v2);
        EDBObject v22 = new EDBObject("/test/object2", data2v2);
        ci.update(v22);

        long time2 = db.commit(ci);

        ci = getEDBCommit();
        Map<String, EDBObjectEntry> data2v3 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 2a", data2v3);
        putValue("KeyB", "Value A 1", data2v3);
        EDBObject v32 = new EDBObject("/test/object2", data2v3);
        ci.update(v32);
        Map<String, EDBObjectEntry> data4v1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 4", data4v1);
        putValue("KeyB", "Value A 1", data4v1);
        EDBObject v33 = new EDBObject("/test/object4", data4v1);
        ci.insert(v33);

        long time3 = db.commit(ci);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("KeyB", "Value A 1");
View Full Code Here

        EngineeringDatabaseService edbService = mock(EngineeringDatabaseService.class);
        EDBConverter converter = new EDBConverter(edbService);
        List<EKBPreCommitHook> preHooks = new ArrayList<EKBPreCommitHook>();
        List<EKBPostCommitHook> postHooks = new ArrayList<EKBPostCommitHook>();
        List<EKBErrorHook> errorHooks = new ArrayList<EKBErrorHook>();
        EDBCommit result = mock(EDBCommit.class);
        when(edbService.createEDBCommit(anyListOf(EDBObject.class), anyListOf(EDBObject.class),
            anyListOf(EDBObject.class))).thenReturn(result);
        this.service = new PersistInterfaceService(edbService, converter, preHooks, postHooks, errorHooks
            , "DEACTIVED");
        ContextHolder.get().setCurrentContextId("test");
View Full Code Here

     * instead.
     */
    private Long runErrorHooks(EDBCommit commit, EDBException exception) throws EDBException {
        for (EDBErrorHook hook : errorHooks) {
            try {
                EDBCommit newCommit = hook.onError(commit, exception);
                if (newCommit != null) {
                    return commit(newCommit);
                }
            } catch (ServiceUnavailableException e) {
                // Ignore
View Full Code Here

     * Performs the actual revert logic including the context locking and the context head revision check if desired.
     */
    private void performRevertLogic(String revision, UUID expectedContextHeadRevision, boolean expectedHeadCheck) {
        String contextId = "";
        try {
            EDBCommit commit = edbService.getCommitByRevision(revision);
            contextId = commit.getContextId();
            lockContext(contextId);
            if (expectedHeadCheck) {
                checkForContextHeadRevision(contextId, expectedContextHeadRevision);
            }
            EDBCommit newCommit = edbService.createEDBCommit(new ArrayList<EDBObject>(),
                new ArrayList<EDBObject>(), new ArrayList<EDBObject>());
            for (EDBObject reverted : commit.getObjects()) {
                // need to be done in order to avoid problems with conflict detection
                reverted.remove(EDBConstants.MODEL_VERSION);
                newCommit.update(reverted);
            }
            for (String delete : commit.getDeletions()) {
                newCommit.delete(delete);
            }
            newCommit.setComment(String.format("revert [%s] %s", commit.getRevisionNumber().toString(),
                commit.getComment() != null ? commit.getComment() : ""));
            edbService.commit(newCommit);
        } catch (EDBException e) {
            throw new EKBException("Unable to revert to the given revision " + revision, e);
        } finally {
View Full Code Here

    /**
     * Performs the persisting of the models into the EDB.
     */
    private void performPersisting(ConvertedCommit commit, EKBCommit source) throws EKBException {
        try {
            EDBCommit ci = edbService.createEDBCommit(commit.getInserts(), commit.getUpdates(), commit.getDeletes());
            ci.setDomainId(source.getDomainId());
            ci.setConnectorId(source.getConnectorId());
            ci.setInstanceId(source.getInstanceId());
            ci.setComment(source.getComment());
            edbService.commit(ci);
            source.setRevisionNumber(ci.getRevisionNumber());
            source.setParentRevisionNumber(ci.getParentRevisionNumber());
        } catch (EDBCheckException e) {
            throw new ModelPersistException(convertEDBObjectList(e.getFailedInserts()),
                convertEDBObjectList(e.getFailedUpdates()), e.getFailedDeletes(), e);
        } catch (EDBException e) {
            throw new EKBException("Error while commiting EKBCommit", e);
View Full Code Here

    @Test
    public void testCommit_shouldWork() throws Exception {
        EDBObject obj = new EDBObject("Tester");
        obj.putEDBObjectEntry("Test", "Hooray");
        EDBCommit ci = db.createEDBCommit(Arrays.asList(obj), null, null);

        long time = db.commit(ci);

        obj = null;
        obj = db.getObject("Tester");
View Full Code Here

    @Test
    public void testGetCommits_shouldWork() throws Exception {
        EDBObject obj = new EDBObject("TestObject");
        obj.putEDBObjectEntry("Bla", "Blabla");
        EDBCommit ci = db.createEDBCommit(Arrays.asList(obj), null, null);

        long time = db.commit(ci);

        List<EDBCommit> commits1 = db.getCommitsByKeyValue("context", "testcontext");
        List<EDBCommit> commits2 = db.getCommitsByKeyValue("context", "DoesNotExist");
View Full Code Here

        HashMap<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("Lock", "Key", data1);
        putValue("Door", "Bell", data1);
        putValue("Cat", "Spongebob", data1);
        EDBObject v1 = new EDBObject("/history/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/1"));
        ci.insert(v1);

        time1 = db.commit(ci);

        HashMap<String, EDBObjectEntry> data2 = (HashMap<String, EDBObjectEntry>) data1.clone();
        putValue("Lock", "Smith", data2);
        EDBObject v2 = new EDBObject("/history/object", data2);
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/2"));
        ci.update(v2);

        time2 = db.commit(ci);

        HashMap<String, EDBObjectEntry> data3 = (HashMap<String, EDBObjectEntry>) data2.clone();
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/3"));
        ci.insert(createRandomTestObject("/useless/4"));
        time3 = db.commit(ci);

        putValue("Cat", "Dog", data3);
        EDBObject v3 = new EDBObject("/history/object", data3);
        ci = getEDBCommit();
        ci.update(v3);
        ci.insert(createRandomTestObject("/useless/5"));

        time4 = db.commit(ci);

        List<EDBObject> history = db.getHistory("/history/object");
View Full Code Here

        checkTimeStamps(Arrays.asList(time1, time2, time3, time4));
    }

    @Test
    public void testHistoryOfDeletion_shouldWork() throws Exception {
        EDBCommit ci = getEDBCommit();
        ci.insert(createRandomTestObject("/deletion/1"));
        long time1 = db.commit(ci);

        ci = getEDBCommit();
        ci.delete("/deletion/1");
        long time2 = db.commit(ci);

        List<EDBObject> history = db.getHistory("/deletion/1");

        assertThat(history.size(), is(2));
View Full Code Here

TOP

Related Classes of org.openengsb.core.edb.api.EDBCommit

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.