use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class AbstractBeanBuilder method create.
public <T> T create(final Class<T> beanClass) {
final ClassInfo classInfo = classRepository.getOrCreateClassInfo(beanClass);
final PresentationModel model = buildPresentationModel(classInfo);
return createInstanceForClass(classInfo, beanClass, model, UpdateSource.SELF);
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class BeanRepositoryImpl method delete.
@Override
public <T> void delete(T bean) {
DolphinUtils.assertIsDolphinBean(bean);
final PresentationModel model = objectPmToDolphinPm.remove(bean);
if (model != null) {
dolphinIdToObjectPm.remove(model.getId());
modelStore.remove(model);
}
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replacingSingleElementAtBeginningAsUser_shouldReplaceElement.
// ////////////////////////////////////////////////////////////
// Replacing elements from different positions as user
// ////////////////////////////////////////////////////////////
@Test
public void replacingSingleElementAtBeginningAsUser_shouldReplaceElement() {
// given :
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newValue = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getPrimitiveList().set(0, newValue);
// then :
final List<ServerPresentationModel> changes = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
assertThat(changes, hasSize(1));
final PresentationModel change = changes.get(0);
assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "primitiveList")));
assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("0").getValue(), allOf(instanceOf(String.class), is((Object) newValue)));
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method addingSingleElementInMiddleFromDolphin_shouldAddElement.
@Test
public void addingSingleElementInMiddleFromDolphin_shouldAddElement() {
// given :
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final String newElement = "42";
model.getPrimitiveList().addAll(Arrays.asList("1", "2", "3"));
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
new PresentationModelBuilder(serverModelStore, PlatformRemotingConstants.LIST_SPLICE).withAttribute("source", sourceModel.getId()).withAttribute("attribute", "primitiveList").withAttribute("from", 1).withAttribute("to", 1).withAttribute("count", 1).withAttribute("0", newElement).create();
// then :
assertThat(model.getPrimitiveList(), is(Arrays.asList("1", newElement, "2", "3")));
assertThat(serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE), empty());
}
use of com.canoo.dp.impl.remoting.legacy.core.PresentationModel in project dolphin-platform by canoo.
the class TestObservableListSync method replaceObjectElementWithNullAsUser_shouldReplaceElement.
@Test
public void replaceObjectElementWithNullAsUser_shouldReplaceElement() {
// given :
final ServerModelStore serverModelStore = createServerModelStore();
final BeanManager manager = createBeanManager(serverModelStore);
final ListReferenceModel model = manager.create(ListReferenceModel.class);
final PresentationModel sourceModel = serverModelStore.findAllPresentationModelsByType(ListReferenceModel.class.getName()).get(0);
final SimpleTestModel oldObject = manager.create(SimpleTestModel.class);
model.getObjectList().add(oldObject);
removeAllPresentationModelsOfType(serverModelStore, PlatformRemotingConstants.LIST_SPLICE);
// when :
model.getObjectList().set(0, null);
// then :
final List<ServerPresentationModel> changes = serverModelStore.findAllPresentationModelsByType(PlatformRemotingConstants.LIST_SPLICE);
assertThat(changes, hasSize(1));
final PresentationModel change = changes.get(0);
assertThat(change.getAttribute("source").getValue(), allOf(instanceOf(String.class), is((Object) sourceModel.getId())));
assertThat(change.getAttribute("attribute").getValue(), allOf(instanceOf(String.class), is((Object) "objectList")));
assertThat(change.getAttribute("from").getValue(), allOf(instanceOf(Integer.class), is((Object) 0)));
assertThat(change.getAttribute("to").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("count").getValue(), allOf(instanceOf(Integer.class), is((Object) 1)));
assertThat(change.getAttribute("0").getValue(), nullValue());
}
Aggregations