use of edu.stanford.bmir.protege.web.shared.collection.CollectionItemData 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.collection.CollectionItemData in project webprotege by protegeproject.
the class GetFormDescriptorActionHander method getDummy.
private GetFormDescriptorResult getDummy(CollectionId collectionId, FormId formId, CollectionItem elementId) {
try {
URL url = GetFormDescriptorActionHander.class.getResource("/amino-acid-form.json");
System.out.println(url);
InputStream is = GetFormDescriptorActionHander.class.getResourceAsStream("/amino-acid-form.json");
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addDeserializer(FormDataValue.class, new FormDataValueDeserializer(dataFactory));
mapper.registerModule(module);
mapper.setDefaultPrettyPrinter(new DefaultPrettyPrinter());
FormDescriptor d = mapper.readerFor(FormDescriptor.class).readValue(new BufferedInputStream(is));
is.close();
CollectionItemData formData = repository.find(collectionId, elementId);
return new GetFormDescriptorResult(projectId, collectionId, elementId, formId, d, formData.getFormData().orElse(FormData.empty()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItemData 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();
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItemData 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));
}
use of edu.stanford.bmir.protege.web.shared.collection.CollectionItemData in project webprotege by protegeproject.
the class CollectionElementDataRepository_IT method shouldFindByCollectionId.
@Test
public void shouldFindByCollectionId() {
CollectionItemData data = new CollectionItemData(collectionId, elementId);
repository.save(data);
assertThat(repository.find(collectionId), hasItem(data));
}
Aggregations