use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue 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