Search in sources :

Example 1 with OPropertyModel

use of ru.ydn.wicket.wicketorientdb.model.OPropertyModel in project wicket-orientdb by OrienteerBAP.

the class TestModels method testOPropertyModel.

@Test
public void testOPropertyModel() {
    OProperty userNameProperty = wicket.getTester().getSchema().getClass("OUser").getProperty("name");
    OPropertyModel propertyModel = new OPropertyModel("OUser", "name");
    assertModelObjectEquals(userNameProperty, propertyModel);
    // Test for null
    propertyModel.setObject(null);
    assertModelObjectEquals(null, propertyModel);
    // Test for classRename
    OClass newClass = wicket.getTester().getSchema().createClass("TestRenameOProperty");
    OProperty property = newClass.createProperty("newProperty", OType.STRING);
    propertyModel.setObject(property);
    assertModelObjectEquals(property, propertyModel);
    property.setName("newProperty2");
    assertModelObjectEquals(property, propertyModel);
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Test(org.junit.Test)

Example 2 with OPropertyModel

use of ru.ydn.wicket.wicketorientdb.model.OPropertyModel in project wicket-orientdb by OrienteerBAP.

the class TestModels method testOPropertyNamingModel.

@Test
public void testOPropertyNamingModel() {
    IModel<String> classNameModel = Model.of("OUser");
    IModel<OClass> oClassModel = new OClassModel(classNameModel);
    IModel<OProperty> propertyModel = new OPropertyModel(oClassModel, "name");
    OPropertyNamingModel model = new OPropertyNamingModel(propertyModel);
    assertModelObjectEquals("Name", model);
    model.detach();
    classNameModel.setObject("ORole");
    assertModelObjectEquals("Role Name", model);
}
Also used : OPropertyNamingModel(ru.ydn.wicket.wicketorientdb.model.OPropertyNamingModel) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClassModel(ru.ydn.wicket.wicketorientdb.model.OClassModel) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) Test(org.junit.Test)

Example 3 with OPropertyModel

use of ru.ydn.wicket.wicketorientdb.model.OPropertyModel in project wicket-orientdb by OrienteerBAP.

the class TestModels method testODocumentLinksDataProvider.

@Test
public void testODocumentLinksDataProvider() {
    ODocument doc1 = new ODocument("ClassA");
    doc1.field("name", "doc1Ext");
    doc1.save();
    ODocument doc2 = new ODocument("ClassA");
    doc2.field("name", "doc2Ext");
    doc2.field("other", Arrays.asList(doc1));
    try {
        ODocumentModel documentModel = new ODocumentModel(doc2);
        OPropertyModel propertyModel = new OPropertyModel("ClassA", "other");
        ODocumentLinksDataProvider provider = new ODocumentLinksDataProvider(documentModel, propertyModel);
        assertEquals(1, provider.size());
        assertEquals(doc1, provider.iterator(0, 1).next());
        doc2.save();
        provider.detach();
        assertEquals(1, provider.size());
        assertEquals(doc1, provider.iterator(0, 1).next());
    } finally {
        doc1.delete();
        doc2.delete();
    }
}
Also used : ODocumentLinksDataProvider(ru.ydn.wicket.wicketorientdb.model.ODocumentLinksDataProvider) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) ODocumentModel(ru.ydn.wicket.wicketorientdb.model.ODocumentModel) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 OPropertyModel (ru.ydn.wicket.wicketorientdb.model.OPropertyModel)3 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)2 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OClassModel (ru.ydn.wicket.wicketorientdb.model.OClassModel)1 ODocumentLinksDataProvider (ru.ydn.wicket.wicketorientdb.model.ODocumentLinksDataProvider)1 ODocumentModel (ru.ydn.wicket.wicketorientdb.model.ODocumentModel)1 OPropertyNamingModel (ru.ydn.wicket.wicketorientdb.model.OPropertyNamingModel)1