Skip to content

Commit

Permalink
Update workflow API for new references, fix search engine, add export…
Browse files Browse the repository at this point in the history
… as TSV of tables
  • Loading branch information
christopher-mohr committed Sep 7, 2017
1 parent 73a8242 commit 8b84bd4
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 199 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* QBiC Project qNavigator enables users to manage their projects. Copyright (C) "2016”
* Christopher Mohr, David Wojnar, Andreas Friedrich
* QBiC Project qNavigator enables users to manage their projects. Copyright (C) "2016” Christopher
* Mohr, David Wojnar, Andreas Friedrich
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
Expand All @@ -20,14 +20,6 @@
import java.util.List;
import java.util.Map;

import logging.Log4j2Logger;
import logging.Logger;
import model.BiologicalEntitySampleBean;
import model.BiologicalSampleBean;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Vocabulary;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.VocabularyTerm;

import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
import com.vaadin.data.util.BeanItemContainer;
Expand All @@ -37,9 +29,12 @@
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.event.SelectionEvent;
import com.vaadin.event.SelectionEvent.SelectionListener;
import com.vaadin.server.FileDownloader;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.StreamResource;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Grid;
import com.vaadin.ui.HorizontalLayout;
Expand All @@ -55,6 +50,15 @@
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickListener;
import com.vaadin.ui.renderers.HtmlRenderer;

import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Vocabulary;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.VocabularyTerm;
import helpers.Utils;
import logging.Log4j2Logger;
import logging.Logger;
import model.BiologicalEntitySampleBean;
import model.BiologicalSampleBean;


public class BiologicalSamplesComponent extends CustomComponent {

Expand All @@ -81,6 +85,12 @@ private enum propertyTypes {
private BeanItemContainer<BiologicalSampleBean> samplesBio;
private BeanItemContainer<BiologicalEntitySampleBean> samplesEntity;
private String currentID;
private Button exportSources = new Button("Export as TSV");
private Button exportSamples = new Button("Export as TSV");
private FileDownloader fileDownloaderSources;
private FileDownloader fileDownloaderSamples;



/**
*
Expand All @@ -89,7 +99,8 @@ private enum propertyTypes {
* @param resourceurl
* @param caption
*/
public BiologicalSamplesComponent(DataHandler dh, State state, String resourceurl, String caption) {
public BiologicalSamplesComponent(DataHandler dh, State state, String resourceurl,
String caption) {
this.datahandler = dh;
this.resourceUrl = resourceurl;
this.state = state;
Expand Down Expand Up @@ -136,6 +147,9 @@ public void select(SelectionEvent event) {
mainLayout.setResponsive(true);
setResponsive(true);

exportSources.setIcon(FontAwesome.DOWNLOAD);
exportSamples.setIcon(FontAwesome.DOWNLOAD);

// this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
this.setCompositionRoot(mainLayout);
}
Expand Down Expand Up @@ -288,12 +302,10 @@ public Class<String> getType() {

@Override
public String getValue(Item item, Object itemId, Object propertyId) {
String ncbi =
String
.format(
"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Undef&name=%s&lvl=0&srchmode=1&keep=1&unlock' target='_blank'>%s</a>",
item.getItemProperty("organism").getValue(),
item.getItemProperty("organismName").getValue());
String ncbi = String.format(
"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Undef&name=%s&lvl=0&srchmode=1&keep=1&unlock' target='_blank'>%s</a>",
item.getItemProperty("organism").getValue(),
item.getItemProperty("organismName").getValue());
String link = String.format("<a href='%s", ncbi);

return link;
Expand Down Expand Up @@ -432,8 +444,8 @@ public void click(RendererClickEvent event) {

subWindow.addCloseListener(new CloseListener() {
/**
*
*/
*
*/
private static final long serialVersionUID = -1329152609834711109L;

@Override
Expand All @@ -445,7 +457,8 @@ public void windowClose(CloseEvent e) {
QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
ui.addWindow(subWindow);
} catch (NullPointerException e) {
System.err.println("NullPointerException while trying to set metadata: " + e.getMessage());
System.err
.println("NullPointerException while trying to set metadata: " + e.getMessage());

}
}
Expand All @@ -460,6 +473,23 @@ public void windowClose(CloseEvent e) {

helpers.GridFunctions.addColumnFilters(sampleBioGrid, gpcBio);
helpers.GridFunctions.addColumnFilters(sampleEntityGrid, gpcEntity);


if (fileDownloaderSources != null)
exportSources.removeExtension(fileDownloaderSources);
StreamResource srSource = Utils.getTSVStream(Utils.containerToString(samplesEntityContainer),
String.format("%s_%s_", id.substring(1).replace("/", "_"), "sample_sources"));
fileDownloaderSources = new FileDownloader(srSource);
fileDownloaderSources.extend(exportSources);


if (fileDownloaderSamples != null)
exportSamples.removeExtension(fileDownloaderSamples);
StreamResource srSamples = Utils.getTSVStream(Utils.containerToString(samplesBioContainer),
String.format("%s_%s_", id.substring(1).replace("/", "_"), "extracted_samples"));
fileDownloaderSamples = new FileDownloader(srSamples);
fileDownloaderSamples.extend(exportSamples);

this.buildLayout();
}

Expand All @@ -481,30 +511,29 @@ private void buildLayout() {
tableSectionContent.setResponsive(true);
sampletableSectionContent.setResponsive(true);

tableSectionContent.setMargin(new MarginInfo(true, false, true, false));
tableSectionContent.setMargin(new MarginInfo(true, false, false, false));
sampletableSectionContent.setMargin(new MarginInfo(true, false, false, false));

// tableSectionContent.setCaption("Datasets");
// tableSectionContent.setIcon(FontAwesome.FLASK);
tableSection
.addComponent(new Label(
String
.format(
"This view shows the sample sources (e.g., human, mouse) to be studied and the corresponding extracted samples. With sample sources, information specific to the subject (e.g., age or BMI in the case of patient data) can be stored. The extracted sample is a sample which has been extracted from the corresponding sample source. This is the raw sample material that can be later prepared for specific analytical methods such as MS or NGS.<br> "
+ "\n\n There are %s extracted samples coming from %s distinct sample sources in this study.",
numberOfBioSamples, numberOfEntitySamples), ContentMode.HTML));
tableSection.addComponent(new Label(String.format(
"This view shows the sample sources (e.g., human, mouse) to be studied and the corresponding extracted samples. With sample sources, information specific to the subject (e.g., age or BMI in the case of patient data) can be stored. The extracted sample is a sample which has been extracted from the corresponding sample source. This is the raw sample material that can be later prepared for specific analytical methods such as MS or NGS.<br> "
+ "\n\n There are %s extracted samples coming from %s distinct sample sources in this study.",
numberOfBioSamples, numberOfEntitySamples), ContentMode.HTML));

tableSectionContent.addComponent(sampleBioGrid);
sampletableSectionContent.addComponent(sampleEntityGrid);

sampleEntityGrid.setCaption("Sample Sources");
sampleBioGrid.setCaption("Extracted Samples");

tableSection.setMargin(new MarginInfo(true, false, false, true));
tableSection.setMargin(new MarginInfo(true, false, true, true));
tableSection.setSpacing(true);

tableSection.addComponent(sampletableSectionContent);
tableSection.addComponent(exportSources);
tableSection.addComponent(tableSectionContent);
tableSection.addComponent(exportSamples);
this.vert.addComponent(tableSection);

sampleBioGrid.setWidth(100, Unit.PERCENTAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FileDownloader;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Resource;
import com.vaadin.server.StreamResource;
Expand All @@ -62,6 +64,7 @@
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample;
import de.uni_tuebingen.qbic.util.DashboardUtil;
import helpers.UglyToPrettyNameMapper;
import helpers.Utils;
import logging.Log4j2Logger;
import logging.Logger;
import model.DatasetBean;
Expand All @@ -87,6 +90,9 @@ public class DatasetComponent extends CustomComponent {
private final ButtonLink download =
new ButtonLink(DOWNLOAD_BUTTON_CAPTION, new ExternalResource(""));

private Button export = new Button("Export as TSV");
private FileDownloader fileDownloader;

private final String[] FILTER_TABLE_COLUMNS =
new String[] {"Select", "File Name", "Dataset Type", "Registration Date", "File Size"};

Expand Down Expand Up @@ -189,6 +195,8 @@ public void updateUI(String type, String id) {
}

numberOfDatasets = retrievedDatasets.size();

BeanItemContainer<DatasetBean> forExport = new BeanItemContainer(DatasetBean.class);
if (numberOfDatasets == 0) {

if (type.equals("project")) {
Expand Down Expand Up @@ -240,14 +248,24 @@ public void updateUI(String type, String id) {
String dateString = sd.format(date);
// Timestamp ts = Timestamp.valueOf(dateString);
String sampleID = samples.get(d.getCode());
forExport.addBean(d);

registerDatasetInTable(d, datasetContainer, projectCode, sampleID, dateString, null);
}
}

this.setContainerDataSource(datasetContainer);

} catch (Exception e) {
if (fileDownloader != null)
this.export.removeExtension(fileDownloader);
StreamResource sr = Utils.getTSVStream(Utils.containerToString(forExport),
String.format("%s_%s_", id.substring(1).replace("/", "_"), "registered_datasets"));
fileDownloader = new FileDownloader(sr);
fileDownloader.extend(export);

} catch (

Exception e) {
e.printStackTrace();
LOGGER.error(String.format("getting dataset failed for dataset %s %s", type, id),
e.getStackTrace());
Expand Down Expand Up @@ -355,6 +373,9 @@ public void buttonClick(ClickEvent event) {
+ "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> "
+ "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>";


export.setIcon(FontAwesome.DOWNLOAD);

PopupView tooltip = new PopupView(new helpers.ToolTip(content));
tooltip.setHeight("44px");

Expand All @@ -373,6 +394,7 @@ public void buttonClick(ClickEvent event) {
help.addComponent(helpContent);
help.setComponentAlignment(helpContent, Alignment.TOP_CENTER);

buttonLayout.addComponent(export);
buttonLayout.addComponent(checkAll);
buttonLayout.addComponent(uncheckAll);
// buttonLayout.addComponent(visualize);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* QBiC Project qNavigator enables users to manage their projects. Copyright (C) "2016”
* Christopher Mohr, David Wojnar, Andreas Friedrich
* QBiC Project qNavigator enables users to manage their projects. Copyright (C) "2016” Christopher
* Mohr, David Wojnar, Andreas Friedrich
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
Expand All @@ -15,17 +15,10 @@
*******************************************************************************/
package de.uni_tuebingen.qbic.qbicmainportlet;

import helpers.Utils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import logging.Log4j2Logger;
import logging.Logger;
import model.ExperimentBean;
import model.ProjectBean;

import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
import com.vaadin.data.util.GeneratedPropertyContainer;
Expand All @@ -49,6 +42,12 @@
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickListener;

import helpers.Utils;
import logging.Log4j2Logger;
import logging.Logger;
import model.ExperimentBean;
import model.ProjectBean;

public class ExperimentComponent extends CustomComponent {
/**
*
Expand Down Expand Up @@ -89,6 +88,7 @@ private void initUI() {
expSteps.setSpacing(true);

export = new Button("Export as TSV");
export.setIcon(FontAwesome.DOWNLOAD);
VerticalLayout buttonLayoutSection = new VerticalLayout();
HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.setHeight(null);
Expand All @@ -107,10 +107,9 @@ private void initUI() {
// experiments.setContainerDataSource(new
// BeanItemContainer<ExperimentBean>(ExperimentBean.class));

expSteps
.addComponent(new Label(
"This view shows the experimental steps which have been registered for this project. Experimental steps contain real biological experiments as well as executed computational workflows on project data",
ContentMode.HTML));
expSteps.addComponent(new Label(
"This view shows the experimental steps which have been registered for this project. Experimental steps contain real biological experiments as well as executed computational workflows on project data",
ContentMode.HTML));

expSteps.addComponent(experiments);
expSteps.addComponent(buttonLayoutSection);
Expand Down Expand Up @@ -251,8 +250,8 @@ public void click(RendererClickEvent event) {
if (fileDownloader != null)
this.export.removeExtension(fileDownloader);
StreamResource sr =
Utils.getTSVStream(Utils.containerToString(projectBean.getExperiments()),
projectBean.getId());
Utils.getTSVStream(Utils.containerToString(projectBean.getExperiments()), String.format(
"%s_%s_", projectBean.getId().substring(1).replace("/", "_"), "experimental_steps"));
fileDownloader = new FileDownloader(sr);
fileDownloader.extend(export);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private void setExportButton() {
buttonLayout.addComponent(this.export);

StreamResource sr =
Utils.getTSVStream(Utils.containerToString(currentBean.getProjects()), this.caption);
Utils.getTSVStream(Utils.containerToString(currentBean.getProjects()), "project_overview");
FileDownloader fileDownloader = new FileDownloader(sr);
fileDownloader.extend(this.export);
}
Expand Down Expand Up @@ -311,6 +311,7 @@ void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) {
// clean up first
// homeview_content.removeAllComponents();
removeAllComponents();
setSpacing(true);

// updateView(browserWidth, browserWidth, browser);

Expand Down Expand Up @@ -339,6 +340,8 @@ void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) {
// tableSectionContent.setIcon(FontAwesome.TABLE);
// tableSectionContent.addComponent(this.table);
addComponent(projectGrid);
addComponent(buttonLayoutSection);
setExportButton();

setCaption("Sub-Projects");
setIcon(FontAwesome.TABLE);
Expand All @@ -349,6 +352,8 @@ void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) {
projectGrid.setSelectionMode(SelectionMode.SINGLE);
projectGrid.setResponsive(true);

export.setIcon(FontAwesome.DOWNLOAD);

// tableSection.setWidth("100%");
// tableSectionContent.setWidth("100%");

Expand Down
Loading

0 comments on commit 8b84bd4

Please sign in to comment.