diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/metadata/ODMLSectionSerializer.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/metadata/ODMLSectionSerializer.java index 54fad800..4fe0cbff 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/metadata/ODMLSectionSerializer.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/metadata/ODMLSectionSerializer.java @@ -1,11 +1,14 @@ package cz.zcu.kiv.eegdatabase.wui.core.experiments.metadata; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import odml.core.Section; import odml.core.Writer; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.wicket.ajax.json.JSONException; @@ -25,14 +28,18 @@ public void serialize(Section value, JsonGenerator jgen, SerializerProvider prov long start = System.currentTimeMillis(); try { - Writer wr = new Writer(value, true, false); + Writer wr = new Writer(value, true, true); ByteArrayOutputStream stream = new ByteArrayOutputStream(); wr.write(stream, false, false); String xmlString = stream.toString("UTF-8"); // encoding is necessary + + IOUtils.write(xmlString, new FileOutputStream(new File("D:\\tmp\\test.xml"))); + JSONObject jsonObject = XML.toJSONObject(xmlString); // String jsonString = jsonObject.toString(); /// XXX remove this - UTF8 encoding problem. String jsonString = new String(jsonObject.toString().getBytes("UTF-8")); // encoding is necessary + IOUtils.write(jsonString, new FileOutputStream(new File("D:\\tmp\\test.json"))); jgen.writeRawValue(jsonString); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.html index 3c880007..a253dbfb 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.html +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentsDetailPage.html @@ -201,6 +201,13 @@

+ +

+ Metadata +

+
+
+

@@ -261,6 +268,7 @@

+ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataPropertyPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataPropertyPanel.java new file mode 100644 index 00000000..7eb2c30e --- /dev/null +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataPropertyPanel.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * This file is part of the EEG-database project + * + * ========================================== + * + * Copyright (C) 2013 by University of West Bohemia (http://www.zcu.cz/en/) + * + * *********************************************************************************************************************** + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * *********************************************************************************************************************** + * + * ViewMetadataPropertyPanel.java, 2015/02/26 00:01 Jakub Rinkes + ******************************************************************************/ +package cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata; + +import odml.core.Property; + +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.CompoundPropertyModel; +import org.apache.wicket.model.IModel; + +import cz.zcu.kiv.eegdatabase.wui.components.utils.ResourceUtils; + +public class ViewMetadataPropertyPanel extends Panel { + + private static final long serialVersionUID = 1L; + + public ViewMetadataPropertyPanel(String id, IModel model) { + super(id, new CompoundPropertyModel(model)); + + Label name = new Label("name"); + Label value = new Label("value"); + + String definition = model.getObject().getDefinition(); + if (definition != null && !definition.isEmpty()) { + String tooltip = ResourceUtils.getString("label.template.definition.tooltip") + definition; + name.add(AttributeModifier.append("title", tooltip)); + value.add(AttributeModifier.append("title", tooltip)); + } + + add(name, value); + } + +} diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.html new file mode 100644 index 00000000..0e7645ca --- /dev/null +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.html @@ -0,0 +1,52 @@ + + + + + +
+

+

+ + + + + + + + + + +
+
+ + +

+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.java new file mode 100644 index 00000000..0acadc2d --- /dev/null +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/ViewMetadataSectionPanel.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * This file is part of the EEG-database project + * + * ========================================== + * + * Copyright (C) 2013 by University of West Bohemia (http://www.zcu.cz/en/) + * + * *********************************************************************************************************************** + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * *********************************************************************************************************************** + * + * ViewMetadataSectionPanel.java, 2015/02/26 00:01 Jakub Rinkes + ******************************************************************************/ +package cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata; + +import odml.core.Property; +import odml.core.Section; + +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.PropertyListView; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.CompoundPropertyModel; +import org.apache.wicket.model.IModel; + +public class ViewMetadataSectionPanel extends Panel { + + private static final long serialVersionUID = 1L; + + public ViewMetadataSectionPanel(String id, IModel
model) { + super(id, new CompoundPropertyModel
(model)); + + add(new Label("name")); + add(new Label("definition")); + + PropertyListView properties = new PropertyListView("properties") { + + private static final long serialVersionUID = 1L; + + @Override + protected void populateItem(ListItem item) { + item.add(new ViewMetadataPropertyPanel("property", item.getModel())); + } + + @Override + public boolean isVisible() { + return getModelObject() != null && !getModelObject().isEmpty(); + } + }; + + add(properties); + + PropertyListView
sections = new PropertyListView
("sections") { + + private static final long serialVersionUID = 1L; + + @Override + protected void populateItem(ListItem
item) { + item.add(new ViewMetadataSectionPanel("section", item.getModel())); + } + + @Override + public boolean isVisible() { + return getModelObject() != null && !getModelObject().isEmpty(); + } + }; + add(sections); + + } + +} diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateForm.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateForm.java index 1afb855a..da072e15 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateForm.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateForm.java @@ -87,7 +87,7 @@ private void setupViewTemplateFormComponents() { window.setHeightUnit("px"); window.setWidthUnit("px"); - ViewSectionPanel panel = new ViewSectionPanel(window.getContentId(), this.model); + ViewFormSectionPanel panel = new ViewFormSectionPanel(window.getContentId(), this.model); window.setContent(panel); add(window); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplatePropertyPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplatePropertyPanel.java index babd9a13..c38426a4 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplatePropertyPanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplatePropertyPanel.java @@ -77,7 +77,7 @@ protected void onConfigure() { @Override protected String defaultNullLabel() { - return ResourceUtils.getString("text.template.empty.definition"); + return ResourceUtils.getString("text.template.empty.property.definition"); } }); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateSectionPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateSectionPanel.java index 4a2e61c0..6f969532 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateSectionPanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/TemplateSectionPanel.java @@ -133,7 +133,7 @@ protected String defaultNullLabel() { @Override protected String defaultNullLabel() { - return ResourceUtils.getString("text.template.empty.definition"); + return ResourceUtils.getString("text.template.empty.section.definition"); } @Override diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.html similarity index 95% rename from src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.html rename to src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.html index 4de7fffe..2d382246 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.html +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.html @@ -18,7 +18,7 @@ *********************************************************************************************************************** - ViewPropertyPanel.html, 2013/02/27 00:01 Jakub Rinkes + ViewFormPropertyPanel.html, 2013/02/27 00:01 Jakub Rinkes --> diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.java similarity index 93% rename from src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.java rename to src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.java index a5533c5f..7fb4119b 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewPropertyPanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormPropertyPanel.java @@ -18,7 +18,7 @@ * * *********************************************************************************************************************** * - * ViewPropertyPanel.java, 2015/02/26 00:01 Jakub Rinkes + * ViewFormPropertyPanel.java, 2015/02/26 00:01 Jakub Rinkes ******************************************************************************/ package cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template; @@ -36,14 +36,14 @@ import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; -public class ViewPropertyPanel extends Panel { +public class ViewFormPropertyPanel extends Panel { private static final long serialVersionUID = 1L; private TextField textField; private DropDownChoice choice; - public ViewPropertyPanel(String id, IModel model) { + public ViewFormPropertyPanel(String id, IModel model) { super(id, new CompoundPropertyModel(model)); add(new Label("name")); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.html similarity index 95% rename from src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.html rename to src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.html index 9f5da0ab..967c091c 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.html +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.html @@ -18,7 +18,7 @@ *********************************************************************************************************************** - ViewSectionPanel.html, 2013/02/27 00:01 Jakub Rinkes + ViewFormSectionPanel.html, 2013/02/27 00:01 Jakub Rinkes --> diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.java similarity index 87% rename from src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.java rename to src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.java index d011fdd4..9be02c91 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewSectionPanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/metadata/template/ViewFormSectionPanel.java @@ -18,7 +18,7 @@ * * *********************************************************************************************************************** * - * ViewSectionPanel.java, 2015/02/26 00:01 Jakub Rinkes + * ViewFormSectionPanel.java, 2015/02/26 00:01 Jakub Rinkes ******************************************************************************/ package cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template; @@ -32,11 +32,11 @@ import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; -public class ViewSectionPanel extends Panel { +public class ViewFormSectionPanel extends Panel { private static final long serialVersionUID = 1L; - public ViewSectionPanel(String id, IModel
model) { + public ViewFormSectionPanel(String id, IModel
model) { super(id, new CompoundPropertyModel
(model)); add(new Label("name")); @@ -48,7 +48,7 @@ public ViewSectionPanel(String id, IModel
model) { @Override protected void populateItem(ListItem item) { - item.add(new ViewPropertyPanel("property", item.getModel())); + item.add(new ViewFormPropertyPanel("property", item.getModel())); } }; @@ -60,7 +60,7 @@ protected void populateItem(ListItem item) { @Override protected void populateItem(ListItem
item) { - item.add(new ViewSectionPanel("section", item.getModel())); + item.add(new ViewFormSectionPanel("section", item.getModel())); } }; add(sections); diff --git a/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties b/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties index 0ca95a3c..78a6acb9 100644 --- a/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties +++ b/src/main/resources/cz/zcu/kiv/eegdatabase/wui/app/EEGDataBaseApplication.properties @@ -246,6 +246,7 @@ button.fulltextSearch=Search button.listOfMembers=List of members button.logIn=Log in button.membershipRequest=Membership request +button.metadataLink=Add/Edit metadata button.reset=Reset button.save=Save button.cancel=Cancel @@ -1130,15 +1131,20 @@ label.template.control.checked=Checked label.template.control.definition=Definition label.template.control.addSection=Add section label.template.section=Section +label.template.section.subsections=Subsections label.template.property=Property label.template.property.required=required label.template.templateName=Template name label.template.type=type label.template.value=value +label.template.value.title=Value label.template.definition=definition +label.template.definition.tooltip=Definition: +text.template.empty.section=Empty section text.template.empty.sectionName=Empty section name -text.template.empty.definition=Empty definition +text.template.empty.section.definition=Empty section definition +text.template.empty.property.definition=Empty property definition text.template.empty.propertyName=Empty property name text.template.empty.propertyType=Empty property type text.template.empty.propertyValue=Empty property value