Search in sources :

Example 1 with FormData

use of edu.stanford.bmir.protege.web.shared.form.FormData 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));
}
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 2 with FormData

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

the class SetFormDataActionHandler method execute.

@Nonnull
@Override
public SetFormDataResult execute(@Nonnull SetFormDataAction action, @Nonnull ExecutionContext executionContext) {
    FormData formData = action.getFormData();
    CollectionItemData data = null;
    if (formData.isEmpty()) {
        data = new CollectionItemData(action.getCollectionId(), action.getElementId());
    } else {
        data = new CollectionItemData(action.getCollectionId(), action.getElementId(), formData);
    }
    repository.save(data);
    return new SetFormDataResult();
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData) CollectionItemData(edu.stanford.bmir.protege.web.shared.collection.CollectionItemData) SetFormDataResult(edu.stanford.bmir.protege.web.shared.form.SetFormDataResult) Nonnull(javax.annotation.Nonnull)

Example 3 with FormData

use of edu.stanford.bmir.protege.web.shared.form.FormData 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);
}
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)

Example 4 with FormData

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

the class FormPortletPresenter method setSubject.

private void setSubject(@Nonnull final OWLEntity entity) {
    checkNotNull(entity);
    FormData formData = formPresenter.getFormData();
    // currentSubject.ifPresent(subject -> {
    // dispatchServiceManager.execute(new SetFormDataAction(projectId,
    // new FormId("MyForm"),
    // subject,
    // formData),
    // result -> {});
    // });
    currentSubject = Optional.of(entity);
// dispatchServiceManager.execute(new GetFormDescriptorAction(projectId, new FormId("MyForm"), entity),
// result -> formPresenter.displayForm(result.getFormDescriptor(), result.getFormData()));
}
Also used : FormData(edu.stanford.bmir.protege.web.shared.form.FormData)

Example 5 with FormData

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

Aggregations

FormData (edu.stanford.bmir.protege.web.shared.form.FormData)10 FormDataValue (edu.stanford.bmir.protege.web.shared.form.data.FormDataValue)7 FormElementId (edu.stanford.bmir.protege.web.shared.form.field.FormElementId)7 HashMap (java.util.HashMap)6 CollectionItemData (edu.stanford.bmir.protege.web.shared.collection.CollectionItemData)4 Test (org.junit.Test)3 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)2 FormDataList (edu.stanford.bmir.protege.web.shared.form.data.FormDataList)2 SetFormDataAction (edu.stanford.bmir.protege.web.shared.form.SetFormDataAction)1 SetFormDataResult (edu.stanford.bmir.protege.web.shared.form.SetFormDataResult)1 FormDataObject (edu.stanford.bmir.protege.web.shared.form.data.FormDataObject)1 Nonnull (javax.annotation.Nonnull)1