use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class CollectionElementDataRepository_IT method shouldSaveNonEmptyCollectionElementData.
@Test
public void shouldSaveNonEmptyCollectionElementData() {
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));
assertThat(datastore.getCount(CollectionItemData.class), is(1L));
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class FormDataRepository_IT method shouldStoreData.
// @Test
public void shouldStoreData() throws Exception {
Map<FormElementId, FormDataValue> map = new HashMap<>();
map.put(FormElementId.get("FirstName"), FormDataPrimitive.get("John"));
FormData formData = new FormData(map);
repository.store(projectId, collectionId, new FormId("MyForm"), entity, formData);
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class FormDataRepository_IT method shouldRetriveData.
// @Test
public void shouldRetriveData() throws Exception {
Map<FormElementId, FormDataValue> map = new HashMap<>();
map.put(FormElementId.get("FirstName"), FormDataPrimitive.get("John"));
map.put(FormElementId.get("LastName"), FormDataPrimitive.get("Smith"));
map.put(FormElementId.get("Age"), FormDataPrimitive.get(62));
map.put(FormElementId.get("Tenure"), FormDataPrimitive.get(true));
Map<String, FormDataValue> val = new HashMap<>();
val.put("Street", FormDataPrimitive.get("1265 Welch Road"));
val.put("City", FormDataPrimitive.get("Stanford"));
val.put("State", FormDataPrimitive.get("CA"));
val.put("Zip", FormDataPrimitive.get(94304));
FormDataObject address = new FormDataObject(val);
map.put(FormElementId.get("Address"), address);
map.put(FormElementId.get("Projects"), new FormDataList(Arrays.asList(FormDataPrimitive.get("Protégé Project"), FormDataPrimitive.get("Bioportal"))));
map.put(FormElementId.get("Homepage"), FormDataPrimitive.get(IRI.create("http://www.stanford.edu/~johnsmith")));
FormData formData = new FormData(map);
FormId formId = new FormId("MyForm");
repository.store(projectId, collectionId, formId, entity, formData);
FormData fd = repository.get(projectId, collectionId, formId, entity);
assertThat(fd, Matchers.is(formData));
}
use of edu.stanford.bmir.protege.web.shared.form.field.FormElementId in project webprotege by protegeproject.
the class PropertyValueFormDataTranslator method toFormData.
/**
* Translates the specified property values into form data using the specified binding.
*
* @param propertyValues The property values to be translated.
* @return The form data corresponding to the translated frame.
*/
public FormData toFormData(@Nonnull Set<PropertyValue> propertyValues, @Nonnull Map<OWLProperty, FormElementId> binding) {
ListMultimap<FormElementId, FormDataValue> dataMultiMap = ArrayListMultimap.create();
propertyValues.forEach(propertyValue -> {
OWLProperty entity = propertyValue.getProperty().getEntity();
FormElementId formElementId = binding.get(entity);
if (formElementId != null) {
OWLPrimitiveData owlVal = propertyValue.getValue();
FormDataValue val = toFormDataValue(owlVal);
dataMultiMap.put(formElementId, val);
}
});
Map<FormElementId, FormDataValue> dataMap = new HashMap<>();
for (FormElementId formElementId : dataMultiMap.keySet()) {
List<FormDataValue> dataValues = dataMultiMap.get(formElementId);
if (dataValues.size() == 1) {
dataMap.put(formElementId, dataValues.get(0));
} else {
dataMap.put(formElementId, new FormDataList(dataValues));
}
}
return new FormData(dataMap);
}
Aggregations