Search in sources :

Example 1 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class ClientResponseHandler method handleValueChangedCommand.

private void handleValueChangedCommand(final ValueChangedCommand serverCommand) {
    Attribute attribute = clientModelStore.findAttributeById(serverCommand.getAttributeId());
    if (attribute == null) {
        LOG.warn("C: attribute with id '{}' not found, cannot update to new value '{}'", serverCommand.getAttributeId(), serverCommand.getNewValue());
        return;
    }
    if (attribute.getValue() == null && serverCommand.getNewValue() == null || (attribute.getValue() != null && serverCommand.getNewValue() != null && attribute.getValue().equals(serverCommand.getNewValue()))) {
        return;
    }
    LOG.trace("C: updating '{}' id '{}' from '{}' to '{}' ", attribute.getPropertyName(), serverCommand.getAttributeId(), attribute.getValue(), serverCommand.getNewValue());
    attribute.setValue(serverCommand.getNewValue());
    return;
}
Also used : ClientAttribute(com.canoo.dp.impl.client.legacy.ClientAttribute) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute)

Example 2 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestPropertyValue method testWithSingleReferenceModel.

@Test
public void testWithSingleReferenceModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    final SimpleTestModel ref1 = manager.create(SimpleTestModel.class);
    ref1.getTextProperty().set("ref1_text");
    final SimpleTestModel ref2 = manager.create(SimpleTestModel.class);
    ref2.getTextProperty().set("ref2_text");
    final List<ServerPresentationModel> refPMs = serverModelStore.findAllPresentationModelsByType(SimpleTestModel.class.getName());
    final ServerPresentationModel ref1PM = "ref1_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
    final ServerPresentationModel ref2PM = "ref2_text".equals(refPMs.get(0).getAttribute("text").getValue()) ? refPMs.get(0) : refPMs.get(1);
    final SingleReferenceModel model = manager.create(SingleReferenceModel.class);
    final ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SingleReferenceModel.class.getName()).get(0);
    final Attribute referenceAttribute = dolphinModel.getAttribute("referenceProperty");
    assertThat(referenceAttribute.getValue(), nullValue());
    model.getReferenceProperty().set(ref1);
    assertThat((String) referenceAttribute.getValue(), is(ref1PM.getId()));
    assertThat(model.getReferenceProperty().get(), is(ref1));
    referenceAttribute.setValue(ref2PM.getId());
    assertThat((String) referenceAttribute.getValue(), is(ref2PM.getId()));
    assertThat(model.getReferenceProperty().get(), is(ref2));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) SingleReferenceModel(com.canoo.impl.server.util.SingleReferenceModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) SimpleTestModel(com.canoo.impl.server.util.SimpleTestModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 3 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestPropertyValue method testWithAnnotatedSimpleModel.

@Test
public void testWithAnnotatedSimpleModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    SimpleAnnotatedTestModel model = manager.create(SimpleAnnotatedTestModel.class);
    ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(SimpleAnnotatedTestModel.class.getName()).get(0);
    Attribute textAttribute = dolphinModel.getAttribute("myProperty");
    assertThat(textAttribute.getValue(), nullValue());
    model.getMyProperty().set("Hallo Platform");
    assertThat((String) textAttribute.getValue(), is("Hallo Platform"));
    assertThat(model.getMyProperty().get(), is("Hallo Platform"));
    textAttribute.setValue("Hallo Dolphin");
    assertThat((String) textAttribute.getValue(), is("Hallo Dolphin"));
    assertThat(model.getMyProperty().get(), is("Hallo Dolphin"));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) SimpleAnnotatedTestModel(com.canoo.impl.server.util.SimpleAnnotatedTestModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 4 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestPropertyValue method testWithInheritedModel.

@Test
public void testWithInheritedModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final BeanManager manager = createBeanManager(serverModelStore);
    ChildModel model = manager.create(ChildModel.class);
    ServerPresentationModel dolphinModel = serverModelStore.findAllPresentationModelsByType(ChildModel.class.getName()).get(0);
    Attribute childAttribute = dolphinModel.getAttribute("childProperty");
    assertThat(childAttribute.getValue(), nullValue());
    Attribute parentAttribute = dolphinModel.getAttribute("parentProperty");
    assertThat(parentAttribute.getValue(), nullValue());
    model.getChildProperty().set("Hallo Platform");
    assertThat((String) childAttribute.getValue(), is("Hallo Platform"));
    assertThat(model.getChildProperty().get(), is("Hallo Platform"));
    assertThat(parentAttribute.getValue(), nullValue());
    assertThat(model.getParentProperty().get(), nullValue());
    parentAttribute.setValue("Hallo Dolphin");
    assertThat((String) childAttribute.getValue(), is("Hallo Platform"));
    assertThat(model.getChildProperty().get(), is("Hallo Platform"));
    assertThat((String) parentAttribute.getValue(), is("Hallo Dolphin"));
    assertThat(model.getParentProperty().get(), is("Hallo Dolphin"));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ChildModel(com.canoo.impl.server.util.ChildModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Example 5 with Attribute

use of com.canoo.dp.impl.remoting.legacy.core.Attribute in project dolphin-platform by canoo.

the class TestModelCreation method testWithComplexDataTypesModel.

@Test
public void testWithComplexDataTypesModel() {
    final ServerModelStore serverModelStore = createServerModelStore();
    final EventDispatcher dispatcher = createEventDispatcher(serverModelStore);
    final BeanRepository beanRepository = createBeanRepository(serverModelStore, dispatcher);
    final BeanManager manager = createBeanManager(serverModelStore, beanRepository, dispatcher);
    ComplexDataTypesModel model = manager.create(ComplexDataTypesModel.class);
    assertThat(model, notNullValue());
    assertThat(model.getDateProperty(), notNullValue());
    assertThat(model.getDateProperty().get(), nullValue());
    assertThat(model.getCalendarProperty(), notNullValue());
    assertThat(model.getCalendarProperty().get(), nullValue());
    assertThat(model.getEnumProperty(), notNullValue());
    assertThat(model.getEnumProperty().get(), nullValue());
    assertThat(beanRepository.isManaged(model), is(true));
    List<ServerPresentationModel> dolphinModels = serverModelStore.findAllPresentationModelsByType(ComplexDataTypesModel.class.getName());
    assertThat(dolphinModels, hasSize(1));
    PresentationModel dolphinModel = dolphinModels.get(0);
    List<Attribute> attributes = dolphinModel.getAttributes();
    assertThat(attributes, containsInAnyOrder(allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", nullValue()), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))));
    List<ServerPresentationModel> classModels = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.DOLPHIN_BEAN);
    assertThat(classModels, contains(hasProperty("attributes", containsInAnyOrder(allOf(hasProperty("propertyName", is(PlatformRemotingConstants.JAVA_CLASS)), hasProperty("value", is(ComplexDataTypesModel.class.getName())), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("dateProperty")), hasProperty("value", is(DateConverterFactory.FIELD_TYPE_DATE)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("calendarProperty")), hasProperty("value", is(CalendarConverterFactory.FIELD_TYPE_CALENDAR)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is("enumProperty")), hasProperty("value", is(EnumConverterFactory.FIELD_TYPE_ENUM)), hasProperty("qualifier", nullValue())), allOf(hasProperty("propertyName", is(RemotingConstants.SOURCE_SYSTEM)), hasProperty("value", is(RemotingConstants.SOURCE_SYSTEM_SERVER)), hasProperty("qualifier", nullValue()))))));
}
Also used : ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) PresentationModel(com.canoo.dp.impl.remoting.legacy.core.PresentationModel) ServerPresentationModel(com.canoo.dp.impl.server.legacy.ServerPresentationModel) EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) ServerAttribute(com.canoo.dp.impl.server.legacy.ServerAttribute) Attribute(com.canoo.dp.impl.remoting.legacy.core.Attribute) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ComplexDataTypesModel(com.canoo.impl.server.util.ComplexDataTypesModel) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.impl.server.util.AbstractDolphinBasedTest)

Aggregations

Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)23 BeanManager (com.canoo.platform.remoting.BeanManager)21 Test (org.testng.annotations.Test)21 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)16 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)15 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)15 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)13 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)13 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)13 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)8 ServerPresentationModel (com.canoo.dp.impl.server.legacy.ServerPresentationModel)8 AbstractDolphinBasedTest (com.canoo.impl.server.util.AbstractDolphinBasedTest)8 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)3 ChildModel (com.canoo.dolphin.client.util.ChildModel)2 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)2 PrimitiveDataTypesModel (com.canoo.dolphin.client.util.PrimitiveDataTypesModel)2 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)2 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)2 ServerAttribute (com.canoo.dp.impl.server.legacy.ServerAttribute)2 ComplexDataTypesModel (com.canoo.impl.server.util.ComplexDataTypesModel)2