Package org.openengsb.core.edb.api

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


     * Creates an instance of the ModelDiff class based on the given model. It loads the old status of the model and
     * calculates the differences of this two models.
     */
    public static ModelDiff createModelDiff(OpenEngSBModel updated, String completeModelId,
            EngineeringDatabaseService edbService, EDBConverter edbConverter) {
        EDBObject queryResult = edbService.getObject(completeModelId);
        OpenEngSBModel old = edbConverter.convertEDBObjectToModel(updated.getClass(), queryResult);
        ModelDiff diff = new ModelDiff(old, updated);
        calculateDifferences(diff);
        return diff;
    }
View Full Code Here


    /**
     * Updates all deleted objects with the timestamp, mark them as deleted and persist them through the entity manager.
     */
    private void updateDeletedObjectsThroughEntityManager(List<String> oids, Long timestamp) {
        for (String id : oids) {
            EDBObject o = new EDBObject(id);
            o.updateTimestamp(timestamp);
            o.setDeleted(true);
            JPAObject j = EDBUtils.convertEDBObjectToJPAObject(o);
            entityManager.persist(j);
        }
    }
View Full Code Here

    }

    @Override
    public EDBObject getObject(String arg0, Long timestamp) throws EDBException {
        if (arg0.equals(getModelOid("objectA/reference/1"))) {
            EDBObject edbObject = new EDBObject(getModelOid("objectA/reference/1"));
            edbObject.putEDBObjectEntry("nameA", "firstObject");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SourceModelA.class.getName());
            return edbObject;
        }
        if (arg0.equals(getModelOid("objectA/reference/2"))) {
            EDBObject edbObject = new EDBObject(getModelOid("objectA/reference/2"));
            edbObject.putEDBObjectEntry("nameA", "updatedFirstObject");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SourceModelA.class.getName());
            return edbObject;
        }
        if (arg0.equals(getModelOid("objectB/reference/1"))) {
            EDBObject edbObject = new EDBObject(getModelOid("objectB/reference/1"));
            edbObject.putEDBObjectEntry("nameB", "secondObject");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SourceModelB.class.getName());
            return edbObject;
        }
        if (arg0.equals(getModelOid("objectB/reference/2"))) {
            EDBObject edbObject = new EDBObject(getModelOid("objectB/reference/2"));
            edbObject.putEDBObjectEntry("nameB", "updatedSecondObject");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, SourceModelB.class.getName());
            return edbObject;
        }
        if (arg0.equals(getModelOid("common/reference/1"))) {
            EDBObject edbObject = new EDBObject(getModelOid("common/reference/1"));
            edbObject.putEDBObjectEntry("modelAId", "objectA/reference/1");
            edbObject.putEDBObjectEntry("modelBId", "objectB/reference/1");
            edbObject.putEDBObjectEntry("nameA", "firstObject");
            edbObject.putEDBObjectEntry("nameB", "secondObject");
            edbObject.putEDBObjectEntry("internalModelName", "common/reference/1");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, EngineeringObjectModel.class.getName());
            return edbObject;
        }
        if (arg0.equals(getModelOid("common/reference/2"))) {
            EDBObject edbObject = new EDBObject(getModelOid("common/reference/2"));
            edbObject.putEDBObjectEntry("modelAId", "objectA/reference/1");
            edbObject.putEDBObjectEntry("nameA", "firstObject");
            edbObject.putEDBObjectEntry("internalModelName", "common/reference/2");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, EngineeringObjectModel.class.getName());
            return edbObject;
        }
        return null;
    }
View Full Code Here

    @Override
    public List<EDBObject> query(QueryRequest request) throws EDBException {
        String reference = (String) request.getParameter(EDBConverter.REFERENCE_PREFIX + "%").iterator().next();
        if (reference.equals(getModelOid("objectA/reference/1"))
                || reference.equals(getModelOid("objectB/reference/1"))) {
            EDBObject edbObject = new EDBObject(getModelOid("common/reference/1"));
            edbObject.putEDBObjectEntry("modelAId", "objectA/reference/1");
            edbObject.putEDBObjectEntry("modelBId", "objectB/reference/1");
            edbObject.putEDBObjectEntry("nameA", "firstObject");
            edbObject.putEDBObjectEntry("nameB", "secondObject");
            edbObject.putEDBObjectEntry("internalModelName", "common/reference/1");
            edbObject.putEDBObjectEntry(EDBConstants.MODEL_TYPE, EngineeringObjectModel.class.getName());
            return Arrays.asList(edbObject);
        }
        return new ArrayList<EDBObject>();
    }
View Full Code Here

        persist.commit(commit, query.getLastRevisionNumberOfContext("A"));
        ContextHolder.get().setCurrentContextId("B");
        persist.commit(commit, query.getLastRevisionNumberOfContext("B"));
       
        ContextHolder.get().setCurrentContextId("A");
        EDBObject obj = edbService.getObject(getModelOid(oid));
        assertThat(obj, notNullValue());
        assertThat(obj.getString("name"), is("B"));
        ContextHolder.get().setCurrentContextId("B");
        obj = edbService.getObject(getModelOid(oid));
        assertThat(obj, notNullValue());
        assertThat(obj.getString("name"), is("B"));
    }
View Full Code Here

        assertThat(db, notNullValue());
    }

    @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");
        String hooray = obj.getString("Test");

        assertThat(obj, notNullValue());
        assertThat(hooray, notNullValue());

        checkTimeStamps(Arrays.asList(time));
View Full Code Here

        checkTimeStamps(Arrays.asList(time));
    }

    @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");
View Full Code Here

        long time4 = 0;
        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);
View Full Code Here

        long time4 = 0;
        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("Burger", "Salad", data1);
        putValue("Bla", "Blub", data1);
        putValue("Cheese", "Butter", data1);
        EDBObject v1 = new EDBObject("/history/test/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/1"));
        ci.insert(createRandomTestObject("/deletion/test/1"));
        ci.insert(v1);

        time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data2 = Maps.newHashMap(data1);
        putValue("Burger", "Meat", data2);
        EDBObject v2 = new EDBObject("/history/test/object", data2);
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/2"));
        ci.delete("/deletion/test/1");
        ci.update(v2);
        time2 = db.commit(ci);

        Map<String, EDBObjectEntry> data3 = Maps.newHashMap(data2);
        ci = getEDBCommit();
        ci.insert(createRandomTestObject("/useless/test/3"));
        ci.insert(createRandomTestObject("/useless/test/4"));
        time3 = db.commit(ci);
        putValue("Cheese", "Milk", data3);

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

        time4 = db.commit(ci);
View Full Code Here

        long time3 = 0;
        Map<String, EDBObjectEntry> data1 = new HashMap<String, EDBObjectEntry>();
        putValue("KeyA", "Value A 1", data1);
        putValue("KeyB", "Value B 1", data1);
        putValue("KeyC", "Value C 1", data1);
        EDBObject v1 = new EDBObject("/diff/object", data1);
        EDBCommit ci = getEDBCommit();
        ci.insert(v1);
        time1 = db.commit(ci);

        Map<String, EDBObjectEntry> data2 = Maps.newHashMap(data1);

        putValue("KeyD", "Value D 1", data2);
        putValue("KeyA", "Value A 2", data2);
        EDBObject v2 = new EDBObject("/diff/object", data2);
        ci = getEDBCommit();
        ci.update(v2);
        time2 = db.commit(ci);

        Map<String, EDBObjectEntry> data3 = Maps.newHashMap(data2);

        data3.remove("KeyB");
        putValue("KeyC", "Value C 3", data3);
        EDBObject v3 = new EDBObject("/diff/object", data3);
        ci = getEDBCommit();
        ci.update(v3);
        time3 = db.commit(ci);

        checkTimeStamps(Arrays.asList(time1, time2, time3));
View Full Code Here

TOP

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

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.