use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class CollectionElementDataRepository_IT method shouldFindByCollectionIdAndElementId.
@Test
public void shouldFindByCollectionIdAndElementId() {
Map<FormElementId, FormDataValue> map = new HashMap<>();
map.put(FormElementId.get("theElement"), FormDataPrimitive.get("theValue"));
FormData formData = new FormData(map);
CollectionItemData data = new CollectionItemData(collectionId, elementId, formData);
repository.save(data);
assertThat(repository.find(collectionId, elementId), is(data));
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class FormDataConverter method decodeObject.
@Override
public FormData decodeObject(DBObject fromDBObject, MappedField optionalExtraInfo) {
Map<FormElementId, FormDataValue> map = new HashMap<>();
fromDBObject.keySet().forEach(key -> {
FormDataValue value = valueConverter.decodeObject(fromDBObject.get(key), optionalExtraInfo);
map.put(FormElementId.get(key), value);
});
return new FormData(map);
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class CompositeFieldEditor method getValue.
@Override
public Optional<FormDataValue> getValue() {
GWT.log("[CompositeFieldEditor] Getting values");
Map<String, FormDataValue> childData = new HashMap<>();
for (FormElementId childId : childEditors.keySet()) {
GWT.log("[CompositeFieldEditor] " + childId);
ValueEditor<FormDataValue> childEditor = childEditors.get(childId);
if (childEditor != null) {
Optional<FormDataValue> childValue = childEditor.getValue();
GWT.log("[CompositeFieldEditor] Value: " + childValue);
if (childValue.isPresent()) {
childData.put(childId.getId(), childValue.get());
}
}
}
GWT.log("[CompositeFieldEditor] All values: " + childData);
if (childData.isEmpty()) {
return Optional.empty();
}
FormDataObject theValue = new FormDataObject(childData);
GWT.log("[CompositeFieldEditor] The value: " + theValue);
return Optional.of(theValue);
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class FormPresenter method setFormData.
private void setFormData(@Nonnull FormData formData) {
formView.getElementViews().forEach(view -> {
Optional<FormElementId> theId = view.getId();
if (theId.isPresent()) {
FormElementId id = theId.get();
Optional<FormDataValue> formElementData = formData.getFormElementData(id);
if (formElementData.isPresent()) {
view.getEditor().setValue(formElementData.get());
} else {
view.getEditor().clearValue();
}
updateRequiredValuePresent(view);
} else {
view.getEditor().clearValue();
}
});
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class CollectionElementDataRepository_IT method shouldUpdateCollectionElementData.
@Test
public void shouldUpdateCollectionElementData() {
Map<FormElementId, FormDataValue> map = new HashMap<>();
map.put(FormElementId.get("theElement"), FormDataPrimitive.get("theValue"));
FormData formData = new FormData(map);
repository.save(new CollectionItemData(collectionId, elementId, formData));
Map<FormElementId, FormDataValue> map2 = new HashMap<>();
map.put(FormElementId.get("theElement"), FormDataPrimitive.get("theNewValue"));
FormData theNewformData = new FormData(map2);
repository.save(new CollectionItemData(collectionId, elementId, theNewformData));
assertThat(datastore.getCount(CollectionItemData.class), is(1L));
}
Aggregations