Skip to content

Commit

Permalink
#145 - users are able to download purchased packages and experiment f…
Browse files Browse the repository at this point in the history
…rom the cart.
  • Loading branch information
stebjan committed Jan 26, 2016
1 parent 6adc918 commit 2d5998c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ public FileDTO generate(Experiment exp, MetadataCommand mc, Collection<DataFile>
} catch (Exception e) {
log.error(e.getMessage(), e);
FileUtils.deleteQuietly(file);
throw new RuntimeException(e);
//return null;
return null;

} finally {
FileUtils.deleteOnExitQuietly(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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" })
Expand All @@ -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<SubjectGroup, Integer> subjectGroupFacade;

@SpringBean
private ElectrodeConfService electrodeConfService;
@SpringBean
private LicenseFacade licenseFacade;

Expand Down Expand Up @@ -115,8 +132,31 @@ private void setupComponents(final Model<Experiment> 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<wicket:container wicket:id="experimentText1"></wicket:container><br />
<wicket:container wicket:id="experimentText2"></wicket:container>
<a href="#" wicket:id="detail"><wicket:message key="link.detail"></wicket:message></a>
<span wicket:id="downloadExpLink" ></span>

</span>

Expand Down Expand Up @@ -59,6 +60,7 @@
</tbody>
</table>
</wicket:enclosure>
<a href='#' wicket:id="downloadLink"><wicket:message key="link.download"></wicket:message></a>
</span>

<span wicket:id="membershipPlan">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,7 +74,7 @@ public class OrderItemPanel extends Panel {

private boolean malleable;

public OrderItemPanel(String id, final IModel<OrderItem> model, boolean malleable) {
public OrderItemPanel(String id, final IModel<OrderItem> model, final boolean malleable) {
super(id, new CompoundPropertyModel<OrderItem>(model));

this.malleable = malleable;
Expand Down Expand Up @@ -159,14 +161,17 @@ 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<Void>("detail", ExperimentsDetailPage.class, PageParametersUtils.getDefaultPageParameters(experimentId)));
ExperimentBuyDownloadLinkPanel downloadExpLink = new ExperimentBuyDownloadLinkPanel("downloadExpLink", experiment, new Model<ExperimentLicence>());
downloadExpLink.setVisible(EEGDataBaseSession.get().isExperimentPurchased(experimentId));
experimentContainer.add(downloadExpLink);

membershipPlanContainer.add(new Label("membershipPlanText1", membershipPlanName + researchGroupName));
membershipPlanContainer.add(new BookmarkablePageLink<Void>("detail", MembershipPlansDetailPage.class, PageParametersUtils.getDefaultPageParameters(membershipPlanID)));
final ModalWindow promoCodePopup = this.addPromoCodePopup(modelItem, membershipPlanContainer);


// prepare texts for package container
int packageId;
final int packageId;
String name;
String group;
if (experimentPackage != null) {
Expand Down Expand Up @@ -219,6 +224,17 @@ public void onClick(AjaxRequestTarget target) {
showHideLink.add(showHideLinkLabel);
packageContainer.add(showHideLink);
packageContainer.add(packageExperimentList);
packageContainer.add(
new BookmarkablePageLink<ExperimentsPackageDownloadPage>("downloadLink", ExperimentsPackageDownloadPage.class,
PageParametersUtils.getDefaultPageParameters(packageId)) {

private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() { return !malleable; }

});

packageExperimentList.setVisible(false);

experimentContainer.setOutputMarkupId(true);
Expand Down

0 comments on commit 2d5998c

Please sign in to comment.