Search in sources :

Example 1 with FormId

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

the class CollectionViewPlaceTokenizer method getPlace.

@Override
public CollectionViewPlace getPlace(String token) {
    MatchResult result = regExp.exec(token);
    ProjectId projectId = ProjectId.get(result.getGroup(1));
    CollectionId collectionId = CollectionId.get(result.getGroup(2));
    FormId formId = new FormId(result.getGroup(3));
    String selectionString = result.getGroup(5);
    GWT.log("[CollectionViewPlaceTokenizer] Selection string: " + selectionString);
    Optional<CollectionItem> selection = Optional.ofNullable(selectionString).map(CollectionItem::get);
    return new CollectionViewPlace(projectId, collectionId, formId, selection);
}
Also used : CollectionId(edu.stanford.bmir.protege.web.shared.collection.CollectionId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) CollectionViewPlace(edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace) FormId(edu.stanford.bmir.protege.web.shared.form.FormId) CollectionItem(edu.stanford.bmir.protege.web.shared.collection.CollectionItem) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 2 with FormId

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

the class FormDescriptorDeserializer method deserialize.

@Override
public FormDescriptor deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    if (!jsonElement.isJsonObject()) {
        throw createParseException(jsonElement, "Object");
    }
    JsonObject object = jsonElement.getAsJsonObject();
    String id = object.getAsJsonPrimitive("id").getAsString();
    JsonArray fieldsArray = object.getAsJsonArray("fields");
    List<FormElementDescriptor> formElementDescriptors = new ArrayList<>();
    for (JsonElement fieldElement : fieldsArray) {
        FormElementDescriptor elementDescriptor = jsonDeserializationContext.deserialize(fieldElement, FormElementDescriptor.class);
        formElementDescriptors.add(elementDescriptor);
    }
    return new FormDescriptor(new FormId(id), formElementDescriptors);
}
Also used : FormDescriptor(edu.stanford.bmir.protege.web.shared.form.FormDescriptor) ArrayList(java.util.ArrayList) FormElementDescriptor(edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor) FormId(edu.stanford.bmir.protege.web.shared.form.FormId)

Example 3 with FormId

use of edu.stanford.bmir.protege.web.shared.form.FormId 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 4 with FormId

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

FormId (edu.stanford.bmir.protege.web.shared.form.FormId)4 FormData (edu.stanford.bmir.protege.web.shared.form.FormData)2 FormDataValue (edu.stanford.bmir.protege.web.shared.form.data.FormDataValue)2 FormElementId (edu.stanford.bmir.protege.web.shared.form.field.FormElementId)2 HashMap (java.util.HashMap)2 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 CollectionId (edu.stanford.bmir.protege.web.shared.collection.CollectionId)1 CollectionItem (edu.stanford.bmir.protege.web.shared.collection.CollectionItem)1 FormDescriptor (edu.stanford.bmir.protege.web.shared.form.FormDescriptor)1 FormDataList (edu.stanford.bmir.protege.web.shared.form.data.FormDataList)1 FormDataObject (edu.stanford.bmir.protege.web.shared.form.data.FormDataObject)1 FormElementDescriptor (edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor)1 CollectionViewPlace (edu.stanford.bmir.protege.web.shared.place.CollectionViewPlace)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 ArrayList (java.util.ArrayList)1