diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/ExperimentDownloadProvider.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/ExperimentDownloadProvider.java index 6496123b..6be05337 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/ExperimentDownloadProvider.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/core/experiments/ExperimentDownloadProvider.java @@ -145,8 +145,7 @@ public FileDTO generate(Experiment exp, MetadataCommand mc, Collection } catch (Exception e) { log.error(e.getMessage(), e); FileUtils.deleteQuietly(file); - throw new RuntimeException(e); - //return null; + return null; } finally { FileUtils.deleteOnExitQuietly(file); diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentFormPage.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentFormPage.java index 594b468d..dc869e4f 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentFormPage.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/experiments/ExperimentFormPage.java @@ -22,8 +22,25 @@ ******************************************************************************/ package cz.zcu.kiv.eegdatabase.wui.ui.experiments; -import java.util.*; - +import cz.zcu.kiv.eegdatabase.data.dao.GenericDao; +import cz.zcu.kiv.eegdatabase.data.pojo.*; +import cz.zcu.kiv.eegdatabase.wui.app.EEGDataBaseApplication; +import cz.zcu.kiv.eegdatabase.wui.app.session.EEGDataBaseSession; +import cz.zcu.kiv.eegdatabase.wui.components.form.AjaxWizardButtonBar; +import cz.zcu.kiv.eegdatabase.wui.components.menu.button.ButtonPageMenu; +import cz.zcu.kiv.eegdatabase.wui.components.page.BasePage; +import cz.zcu.kiv.eegdatabase.wui.components.page.MenuPage; +import cz.zcu.kiv.eegdatabase.wui.components.utils.PageParametersUtils; +import cz.zcu.kiv.eegdatabase.wui.components.utils.ResourceUtils; +import cz.zcu.kiv.eegdatabase.wui.core.common.DigitizationFacade; +import cz.zcu.kiv.eegdatabase.wui.core.common.ElectrodeConfService; +import cz.zcu.kiv.eegdatabase.wui.core.common.WeatherFacade; +import cz.zcu.kiv.eegdatabase.wui.core.experimentLicense.ExperimentLicenseFacade; +import cz.zcu.kiv.eegdatabase.wui.core.experiments.ExperimentsFacade; +import cz.zcu.kiv.eegdatabase.wui.core.file.FileFacade; +import cz.zcu.kiv.eegdatabase.wui.core.license.LicenseFacade; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentResultsForm; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentScenarioForm; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.wicket.Component; @@ -42,21 +59,10 @@ import org.apache.wicket.spring.injection.annot.SpringBean; import org.apache.wicket.util.string.StringValue; -import cz.zcu.kiv.eegdatabase.data.pojo.*; -import cz.zcu.kiv.eegdatabase.wui.app.EEGDataBaseApplication; -import cz.zcu.kiv.eegdatabase.wui.app.session.EEGDataBaseSession; -import cz.zcu.kiv.eegdatabase.wui.components.form.AjaxWizardButtonBar; -import cz.zcu.kiv.eegdatabase.wui.components.menu.button.ButtonPageMenu; -import cz.zcu.kiv.eegdatabase.wui.components.page.BasePage; -import cz.zcu.kiv.eegdatabase.wui.components.page.MenuPage; -import cz.zcu.kiv.eegdatabase.wui.components.utils.PageParametersUtils; -import cz.zcu.kiv.eegdatabase.wui.components.utils.ResourceUtils; -import cz.zcu.kiv.eegdatabase.wui.core.experimentLicense.ExperimentLicenseFacade; -import cz.zcu.kiv.eegdatabase.wui.core.experiments.ExperimentsFacade; -import cz.zcu.kiv.eegdatabase.wui.core.file.FileFacade; -import cz.zcu.kiv.eegdatabase.wui.core.license.LicenseFacade; -import cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentResultsForm; -import cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentScenarioForm; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; @AuthorizeInstantiation(value = { "ROLE_USER", "ROLE_EXPERIMENTER", "ROLE_ADMIN" }) @@ -72,6 +78,17 @@ public class ExperimentFormPage extends MenuPage { @SpringBean private FileFacade fileFacade; + @SpringBean + private DigitizationFacade digitizationFacade; + + @SpringBean + private WeatherFacade weatherFacade; + + @SpringBean(name = "subjectGroupDao") + private GenericDao subjectGroupFacade; + + @SpringBean + private ElectrodeConfService electrodeConfService; @SpringBean private LicenseFacade licenseFacade; @@ -115,8 +132,31 @@ private void setupComponents(final Model model) { @Override public void onFinish() { + if (digitizationFacade.getCountRecords() == 0) { + Digitization dig = new Digitization(); + dig.setSamplingRate(1000f); + dig.setGain(1f); + dig.setFilter("filter"); + digitizationFacade.create(dig); + } + if (electrodeConfService.getCountRecords() == 0) { + ElectrodeConf conf = new ElectrodeConf(); + conf.setImpedance(10); + electrodeConfService.create(conf); + } + + if (subjectGroupFacade.getCountRecords() == 0) { + SubjectGroup group = new SubjectGroup(); + group.setDescription("xxx"); + group.setTitle("Title"); + subjectGroupFacade.create(group); + } Experiment experiment = model.getObject(); + experiment.setDigitization(digitizationFacade.read(1)); + experiment.setElectrodeConf(electrodeConfService.read(1)); + experiment.setSubjectGroup(subjectGroupFacade.read(1)); + experiment.setWeather(weatherFacade.read(1)); ResearchGroup group = experiment.getResearchGroup(); if (group != null && group.isLock()) { diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.html b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.html index d4241071..35d64bb9 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.html +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.html @@ -29,6 +29,7 @@
+ @@ -59,6 +60,7 @@ + diff --git a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.java b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.java index 13d4edb0..19074001 100644 --- a/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.java +++ b/src/main/java/cz/zcu/kiv/eegdatabase/wui/ui/order/OrderItemPanel.java @@ -32,6 +32,8 @@ import cz.zcu.kiv.eegdatabase.wui.core.experiments.ExperimentsFacade; import cz.zcu.kiv.eegdatabase.wui.core.promocode.PromoCodeFacade; import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentsDetailPage; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.ExperimentsPackageDownloadPage; +import cz.zcu.kiv.eegdatabase.wui.ui.experiments.components.ExperimentBuyDownloadLinkPanel; import cz.zcu.kiv.eegdatabase.wui.ui.memberships.MembershipPlansDetailPage; import cz.zcu.kiv.eegdatabase.wui.ui.order.components.PromoCodePopupForm; import cz.zcu.kiv.eegdatabase.wui.ui.order.components.StringWrapper; @@ -72,7 +74,7 @@ public class OrderItemPanel extends Panel { private boolean malleable; - public OrderItemPanel(String id, final IModel model, boolean malleable) { + public OrderItemPanel(String id, final IModel model, final boolean malleable) { super(id, new CompoundPropertyModel(model)); this.malleable = malleable; @@ -159,6 +161,9 @@ public boolean isVisible() { experimentContainer.add(new Label("experimentText1", ResourceUtils.getModel("text.order.item.experiment1", Integer.toString(experimentId), scenarioTitle))); experimentContainer.add(new Label("experimentText2", ResourceUtils.getModel("text.order.item.experiment2", date))); experimentContainer.add(new BookmarkablePageLink("detail", ExperimentsDetailPage.class, PageParametersUtils.getDefaultPageParameters(experimentId))); + ExperimentBuyDownloadLinkPanel downloadExpLink = new ExperimentBuyDownloadLinkPanel("downloadExpLink", experiment, new Model()); + downloadExpLink.setVisible(EEGDataBaseSession.get().isExperimentPurchased(experimentId)); + experimentContainer.add(downloadExpLink); membershipPlanContainer.add(new Label("membershipPlanText1", membershipPlanName + researchGroupName)); membershipPlanContainer.add(new BookmarkablePageLink("detail", MembershipPlansDetailPage.class, PageParametersUtils.getDefaultPageParameters(membershipPlanID))); @@ -166,7 +171,7 @@ public boolean isVisible() { // prepare texts for package container - int packageId; + final int packageId; String name; String group; if (experimentPackage != null) { @@ -219,6 +224,17 @@ public void onClick(AjaxRequestTarget target) { showHideLink.add(showHideLinkLabel); packageContainer.add(showHideLink); packageContainer.add(packageExperimentList); + packageContainer.add( + new BookmarkablePageLink("downloadLink", ExperimentsPackageDownloadPage.class, + PageParametersUtils.getDefaultPageParameters(packageId)) { + + private static final long serialVersionUID = 1L; + + @Override + public boolean isVisible() { return !malleable; } + + }); + packageExperimentList.setVisible(false); experimentContainer.setOutputMarkupId(true);