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;
}
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));
}
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"));
}
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"));
}
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()))))));
}
Aggregations