Search in sources :

Example 11 with FormDataValue

use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue in project webprotege by protegeproject.

the class ChoiceFieldComboBoxEditor method getValue.

@Override
public Optional<FormDataValue> getValue() {
    int selIndex = comboBox.getSelectedIndex();
    if (selIndex < 1) {
        return Optional.empty();
    }
    FormDataValue selData = choiceDescriptors.get(selIndex - 1).getValue();
    return Optional.of(selData);
}
Also used : FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue)

Example 12 with FormDataValue

use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue 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));
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData) CollectionItemData(edu.stanford.bmir.protege.web.shared.collection.CollectionItemData) FormElementId(edu.stanford.bmir.protege.web.shared.form.field.FormElementId) HashMap(java.util.HashMap) FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) Test(org.junit.Test)

Example 13 with FormDataValue

use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue 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));
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData) CollectionItemData(edu.stanford.bmir.protege.web.shared.collection.CollectionItemData) FormElementId(edu.stanford.bmir.protege.web.shared.form.field.FormElementId) HashMap(java.util.HashMap) FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) Test(org.junit.Test)

Example 14 with FormDataValue

use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue 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);
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData) FormElementId(edu.stanford.bmir.protege.web.shared.form.field.FormElementId) HashMap(java.util.HashMap) FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) FormId(edu.stanford.bmir.protege.web.shared.form.FormId)

Example 15 with FormDataValue

use of edu.stanford.bmir.protege.web.shared.form.data.FormDataValue 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));
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData) FormDataList(edu.stanford.bmir.protege.web.shared.form.data.FormDataList) FormElementId(edu.stanford.bmir.protege.web.shared.form.field.FormElementId) HashMap(java.util.HashMap) FormDataObject(edu.stanford.bmir.protege.web.shared.form.data.FormDataObject) FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) FormId(edu.stanford.bmir.protege.web.shared.form.FormId)

Aggregations

FormDataValue (edu.stanford.bmir.protege.web.shared.form.data.FormDataValue)16 FormElementId (edu.stanford.bmir.protege.web.shared.form.field.FormElementId)9 HashMap (java.util.HashMap)8 FormData (edu.stanford.bmir.protege.web.shared.form.FormData)7 CollectionItemData (edu.stanford.bmir.protege.web.shared.collection.CollectionItemData)3 FormDataList (edu.stanford.bmir.protege.web.shared.form.data.FormDataList)3 FormDataObject (edu.stanford.bmir.protege.web.shared.form.data.FormDataObject)3 Test (org.junit.Test)3 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 DBObject (com.mongodb.DBObject)1 OWLEntityConverter (edu.stanford.bmir.protege.web.server.persistence.OWLEntityConverter)1 TypeSafeConverter (edu.stanford.bmir.protege.web.server.persistence.TypeSafeConverter)1 FormDataPrimitive (edu.stanford.bmir.protege.web.shared.form.data.FormDataPrimitive)1 ChoiceDescriptor (edu.stanford.bmir.protege.web.shared.form.field.ChoiceDescriptor)1 FormElementDescriptor (edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1