List of usage examples for com.vaadin.ui Grid Grid
public Grid()
From source file:de.uni_tuebingen.qbic.qbicmainportlet.AddPatientView.java
License:Open Source License
/** * /*from www .j av a 2 s. c o m*/ * @return */ void initOptionLayout() { optionLayout.removeAllComponents(); optionLayout.setWidth("100%"); optionLayout.setVisible(false); VerticalLayout optionLayoutContent = new VerticalLayout(); Button addSample = new Button("Add Sample"); addSample.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { sampleOptions.addBean(new NewIvacSampleBean("", 0, "", false, false, false, "", "")); } }); optionLayoutContent.setMargin(new MarginInfo(true, false, false, false)); optionLayoutContent.setHeight(null); optionLayoutContent.setWidth("100%"); optionLayoutContent.setSpacing(true); final Grid optionGrid = new Grid(); optionGrid.setWidth("80%"); // optionGrid.setCaption("Which biological samples are available for the patient(s) and which // experiments will be performed?"); gridInfo = new CustomVisibilityComponent(new Label("")); ((Label) gridInfo.getInnerComponent()).addStyleName(ValoTheme.LABEL_LARGE); Component gridInfoContent = Utils.questionize(gridInfo, "Which biological samples are available for the patient(s) and which experiments will be performed?", "Extracted Samples"); // optionGrid.setSelectionMode(SelectionMode.MULTI); optionGrid.setEditorEnabled(true); optionGrid.setContainerDataSource(sampleOptions); optionGrid.setColumnOrder("type", "secondaryName", "tissue", "amount", "dnaSeq", "rnaSeq", "deepSeq"); optionLayoutContent.addComponent(gridInfoContent); optionLayoutContent.addComponent(optionGrid); optionLayoutContent.addComponent(addSample); final GridEditForm form = new GridEditForm( datahandler.getOpenBisClient().getVocabCodesForVocab("Q_PRIMARY_TISSUES"), datahandler.getOpenBisClient().getVocabCodesForVocab("Q_SEQUENCER_DEVICES")); optionLayoutContent.addComponent(form); form.setVisible(false); optionGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { BeanItem<NewIvacSampleBean> item = sampleOptions.getItem(optionGrid.getSelectedRow()); form.fieldGroup.setItemDataSource(item); form.setVisible(true); } }); optionLayout.addComponent(optionLayoutContent); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.BiologicalSamplesComponent.java
License:Open Source License
/** * //from w w w .j a va 2 s . co m */ private void initUI() { vert = new VerticalLayout(); sampleBioGrid = new Grid(); sampleEntityGrid = new Grid(); vert.setMargin(new MarginInfo(false, true, false, false)); sampleEntityGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { BeanItem<BiologicalEntitySampleBean> selectedBean = samplesEntity .getItem(sampleEntityGrid.getSelectedRow()); if (selectedBean == null) { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(""); } else { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(selectedBean.getBean().getCode()); // samplesBio.addContainerFilter("biologicalEntity", // selectedBean.getBean().getSecondaryName(), false, false); } } }); mainLayout = new VerticalLayout(vert); 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); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.BiologicalSamplesComponent.java
License:Open Source License
/** * //from w w w .ja va2 s . co m * @param id */ public void updateUI(String id) { currentID = id; sampleBioGrid = new Grid(); sampleEntityGrid = new Grid(); sampleEntityGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { BeanItem<BiologicalEntitySampleBean> selectedBean = samplesEntity .getItem(sampleEntityGrid.getSelectedRow()); if (selectedBean == null) { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(""); } else { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(selectedBean.getBean().getCode()); // samplesBio.addContainerFilter("biologicalEntity", // selectedBean.getBean().getSecondaryName(), false, false); } } }); if (id == null) return; BeanItemContainer<BiologicalSampleBean> samplesBioContainer = new BeanItemContainer<BiologicalSampleBean>( BiologicalSampleBean.class); BeanItemContainer<BiologicalEntitySampleBean> samplesEntityContainer = new BeanItemContainer<BiologicalEntitySampleBean>( BiologicalEntitySampleBean.class); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(id); List<VocabularyTerm> terms = null; Map<String, String> termsMap = new HashMap<String, String>(); for (Sample sample : allSamples) { if (sample.getSampleTypeCode().equals(sampleTypes.Q_BIOLOGICAL_ENTITY.toString())) { Map<String, String> sampleProperties = sample.getProperties(); BiologicalEntitySampleBean newEntityBean = new BiologicalEntitySampleBean(); newEntityBean.setCode(sample.getCode()); newEntityBean.setId(sample.getIdentifier()); newEntityBean.setType(sample.getSampleTypeCode()); newEntityBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newEntityBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newEntityBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); String organismID = sampleProperties.get("Q_NCBI_ORGANISM"); newEntityBean.setOrganism(organismID); if (terms != null) { if (termsMap.containsKey(organismID)) { newEntityBean.setOrganismName(termsMap.get(organismID)); } else { for (VocabularyTerm term : terms) { if (term.getCode().equals(organismID)) { newEntityBean.setOrganismName(term.getLabel()); break; } } } } else { for (Vocabulary vocab : datahandler.getOpenBisClient().getFacade().listVocabularies()) { if (vocab.getCode().equals("Q_NCBI_TAXONOMY")) { terms = vocab.getTerms(); for (VocabularyTerm term : vocab.getTerms()) { if (term.getCode().equals(organismID)) { newEntityBean.setOrganismName(term.getLabel()); termsMap.put(organismID, term.getLabel()); break; } } break; } } } newEntityBean.setProperties(sampleProperties); newEntityBean.setGender(sampleProperties.get("Q_GENDER")); samplesEntityContainer.addBean(newEntityBean); // for (Sample child : datahandler.getOpenBisClient().getChildrenSamples(sample)) { for (Sample realChild : sample.getChildren()) { if (realChild.getSampleTypeCode().equals(sampleTypes.Q_BIOLOGICAL_SAMPLE.toString())) { // Sample realChild = // datahandler.getOpenBisClient().getSampleByIdentifier(child.getIdentifier()); Map<String, String> sampleBioProperties = realChild.getProperties(); BiologicalSampleBean newBean = new BiologicalSampleBean(); newBean.setCode(realChild.getCode()); newBean.setId(realChild.getIdentifier()); newBean.setType(realChild.getSampleTypeCode()); newBean.setPrimaryTissue(sampleBioProperties.get("Q_PRIMARY_TISSUE")); newBean.setTissueDetailed(sampleBioProperties.get("Q_TISSUE_DETAILED")); newBean.setBiologicalEntity(sample.getCode()); newBean.setAdditionalInfo(sampleBioProperties.get("Q_ADDITIONAL_INFO")); newBean.setExternalDB(sampleBioProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleBioProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleBioProperties); samplesBioContainer.addBean(newBean); } } } } numberOfBioSamples = samplesBioContainer.size(); numberOfEntitySamples = samplesEntityContainer.size(); samplesBio = samplesBioContainer; samplesEntity = samplesEntityContainer; sampleEntityGrid.removeAllColumns(); final GeneratedPropertyContainer gpcEntity = new GeneratedPropertyContainer(samplesEntity); gpcEntity.removeContainerProperty("id"); gpcEntity.removeContainerProperty("type"); gpcEntity.removeContainerProperty("organismName"); gpcEntity.removeContainerProperty("organism"); sampleEntityGrid.setContainerDataSource(gpcEntity); sampleEntityGrid.setColumnReorderingAllowed(true); gpcEntity.addGeneratedProperty("Organism", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @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 link = String.format("<a href='%s", ncbi); return link; } }); sampleEntityGrid.getColumn("Organism").setRenderer(new HtmlRenderer()); final GeneratedPropertyContainer gpcBio = new GeneratedPropertyContainer(samplesBio); gpcBio.removeContainerProperty("id"); gpcBio.removeContainerProperty("type"); sampleBioGrid.setContainerDataSource(gpcBio); sampleBioGrid.setColumnReorderingAllowed(true); sampleBioGrid.setColumnOrder("secondaryName", "code"); gpcEntity.addGeneratedProperty("edit", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "Edit"; } @Override public Class<String> getType() { return String.class; } }); gpcBio.addGeneratedProperty("edit", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "Edit"; } @Override public Class<String> getType() { return String.class; } }); sampleEntityGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samplesEntity.getItem(event.getItemId()); BiologicalEntitySampleBean selectedExp = (BiologicalEntitySampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); sampleEntityGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samplesEntity.getItem(event.getItemId()); BiologicalEntitySampleBean selectedSample = (BiologicalEntitySampleBean) selected.getBean(); Window subWindow = new Window("Edit Metadata"); changeMetadata.updateUI(selectedSample.getId(), selectedSample.getType()); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); subWindow.setContent(subContent); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setIcon(FontAwesome.PENCIL); subWindow.setHeight("75%"); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(currentID); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } })); sampleEntityGrid.getColumn("edit").setWidth(70); sampleEntityGrid.getColumn("edit").setHeaderCaption(""); sampleEntityGrid.setColumnOrder("edit", "secondaryName", "Organism", "properties", "code", "additionalInfo", "gender", "externalDB"); sampleBioGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samplesBio.getItem(event.getItemId()); BiologicalSampleBean selectedExp = (BiologicalSampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); sampleBioGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samplesBio.getItem(event.getItemId()); try { BiologicalSampleBean selectedSample = (BiologicalSampleBean) selected.getBean(); Window subWindow = new Window(); changeMetadata.updateUI(selectedSample.getId(), selectedSample.getType()); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); subWindow.setContent(subContent); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setResizable(false); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(currentID); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } catch (NullPointerException e) { System.err.println("NullPointerException while trying to set metadata: " + e.getMessage()); } } })); sampleBioGrid.getColumn("edit").setWidth(70); sampleBioGrid.getColumn("edit").setHeaderCaption(""); sampleBioGrid.setColumnOrder("edit", "secondaryName", "primaryTissue", "properties", "tissueDetailed", "code", "additionalInfo", "biologicalEntity", "externalDB"); sampleBioGrid.getColumn("biologicalEntity").setHeaderCaption("Source"); 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(); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentComponent.java
License:Open Source License
private void initUI() { expSteps = new VerticalLayout(); expSteps.setWidth(100.0f, Unit.PERCENTAGE); expSteps.setMargin(new MarginInfo(true, true, true, true)); expSteps.setSpacing(true);//from w w w .j av a 2 s. co m export = new Button("Export as TSV"); export.setIcon(FontAwesome.DOWNLOAD); VerticalLayout buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null); buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, false, false)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, false, false)); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); experiments.setCaption("Registered Experimental Steps"); // 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(experiments); expSteps.addComponent(buttonLayoutSection); setCompositionRoot(expSteps); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.HomeView.java
License:Open Source License
public HomeView(DataHandler datahandler, String caption, String user, State state, String resUrl, String tmpFolderPath) {//w w w. j ava 2s . c o m homeview_content = new VerticalLayout(); // this.table = buildFilterTable(); this.projectGrid = new Grid(); this.datahandler = datahandler; this.state = state; this.resourceUrl = resUrl; this.summaryFetcher = new SummaryFetcher(datahandler.getOpenBisClient(), tmpFolderPath); this.user = user; // tableClickChangeTreeView(); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.HomeView.java
License:Open Source License
/** * sets the ContainerDataSource of this view. Should usually contain project information. Caption * is caption./*from w ww .j a v a 2s .c o m*/ * * @param homeViewInformation * @param caption */ public void setContainerDataSource(SpaceBean spaceBean, String newCaption) { caption = newCaption; currentBean = spaceBean; numberOfProjects = currentBean.getProjects().size(); projectGrid = new Grid(); GeneratedPropertyContainer gpcProjects = new GeneratedPropertyContainer(spaceBean.getProjects()); gpcProjects.removeContainerProperty("members"); gpcProjects.removeContainerProperty("id"); gpcProjects.removeContainerProperty("experiments"); gpcProjects.removeContainerProperty("contact"); gpcProjects.removeContainerProperty("contactPerson"); gpcProjects.removeContainerProperty("projectManager"); gpcProjects.removeContainerProperty("containsData"); gpcProjects.removeContainerProperty("containsResults"); gpcProjects.removeContainerProperty("containsAttachments"); gpcProjects.removeContainerProperty("description"); gpcProjects.removeContainerProperty("progress"); gpcProjects.removeContainerProperty("registrationDate"); gpcProjects.removeContainerProperty("registrator"); gpcProjects.removeContainerProperty("longDescription"); projectGrid.setContainerDataSource(gpcProjects); projectGrid.setHeightMode(HeightMode.ROW); projectGrid.setHeightByRows(20); // projectGrid.getColumn("space").setWidthUndefined(); // projectGrid.getColumn("code").setWidthUndefined(); // projectGrid.getColumn("secondaryName").setWidthUndefined(); // projectGrid.getColumn("principalInvestigator").setWidthUndefined(); projectGrid.getColumn("code").setHeaderCaption("Sub-Project").setWidth(150); // projectGrid.getColumn("space").setWidth(200); Column nameCol = projectGrid.getColumn("secondaryName"); nameCol.setHeaderCaption("Short Name"); nameCol.setMaximumWidth(450); projectGrid.getColumn("space").setMaximumWidth(350); projectGrid.getColumn("space").setHeaderCaption("Project"); projectGrid.getColumn("principalInvestigator").setHeaderCaption("Investigator"); projectGrid.setColumnOrder("code", "space", "secondaryName", "principalInvestigator"); projectGrid.setResponsive(true); helpers.GridFunctions.addColumnFilters(projectGrid, gpcProjects); gpcProjects.addGeneratedProperty("Summary", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "show"; } @Override public Class<String> getType() { return String.class; } }); projectGrid.getColumn("Summary").setWidthUndefined(); projectGrid.getColumn("Summary").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { // Show loading window ProgressBar bar = new ProgressBar(); bar.setIndeterminate(true); VerticalLayout vl = new VerticalLayout(bar); vl.setComponentAlignment(bar, Alignment.MIDDLE_CENTER); vl.setWidth("50%"); vl.setSpacing(true); vl.setMargin(true); Window loadingWindow = new Window("Loading project summary..."); loadingWindow.setWidth("50%"); loadingWindow.setContent(vl); loadingWindow.center(); loadingWindow.setModal(true); loadingWindow.setResizable(false); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(loadingWindow); // fetch summary and create docx in tmp folder ProjectBean proj = (ProjectBean) event.getItemId(); summaryFetcher.fetchSummaryComponent(proj.getCode(), proj.getSecondaryName(), proj.getDescription(), new ProjectSummaryReadyRunnable(summaryFetcher, loadingWindow, proj.getCode())); } })); projectGrid.getColumn("Summary").setWidth(100); projectGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { Set<Object> selectedElements = event.getSelected(); if (selectedElements == null) { return; } ProjectBean selectedProject = (ProjectBean) selectedElements.iterator().next(); if (selectedProject == null) { return; } String entity = selectedProject.getId(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(entity); message.add(ProjectView.navigateToLabel); state.notifyObservers(message); } }); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java
License:Open Source License
private void initUI() { vert = new VerticalLayout(); datasetTable = buildFilterTable();/*from w w w. j a v a2 s. co m*/ sampleGrid = new Grid(); mainLayout = new VerticalLayout(vert); mainLayout.setResponsive(true); vert.setResponsive(true); vert.setMargin(new MarginInfo(false, true, false, false)); setResponsive(true); exportData.setIcon(FontAwesome.DOWNLOAD); exportSamples.setIcon(FontAwesome.DOWNLOAD); // this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS); this.setCompositionRoot(mainLayout); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java
License:Open Source License
public void updateUI(String type, String id, String filterFor) { sampleGrid = new Grid(); typeString = type;/*w ww .j a va2 s. c o m*/ idString = id; filterString = filterFor; if (id == null) return; try { HierarchicalContainer datasetContainer = new HierarchicalContainer(); datasetContainer.addContainerProperty("Select", CheckBox.class, null); datasetContainer.addContainerProperty("Project", String.class, null); datasetContainer.addContainerProperty("Sample", String.class, null); datasetContainer.addContainerProperty("Description", String.class, null); // datasetContainer.addContainerProperty("Sample Type", String.class, null); datasetContainer.addContainerProperty("File Name", String.class, null); datasetContainer.addContainerProperty("File Type", String.class, null); datasetContainer.addContainerProperty("Dataset Type", String.class, null); datasetContainer.addContainerProperty("Registration Date", String.class, null); datasetContainer.addContainerProperty("Validated", Boolean.class, null); datasetContainer.addContainerProperty("File Size", String.class, null); datasetContainer.addContainerProperty("file_size_bytes", Long.class, null); datasetContainer.addContainerProperty("dl_link", String.class, null); datasetContainer.addContainerProperty("isDirectory", Boolean.class, null); datasetContainer.addContainerProperty("CODE", String.class, null); List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> retrievedDatasetsAll = null; List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> retrievedDatasets = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); Map<String, ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>> datasetFilter = new HashMap<String, ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>>(); // clear download queue for new view PortletSession portletSession = ((QbicmainportletUI) UI.getCurrent()).getPortletSession(); portletSession.setAttribute("qbic_download", new HashMap<String, AbstractMap.SimpleEntry<String, Long>>(), PortletSession.APPLICATION_SCOPE); Map<String, Sample> checkedTestSamples = new HashMap<String, Sample>(); switch (type) { case "project": String projectIdentifier = id; retrievedDatasetsAll = datahandler.getOpenBisClient() .getDataSetsOfProjectByIdentifierWithSearchCriteria(projectIdentifier); for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : retrievedDatasetsAll) { ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> values = datasetFilter .get(ds.getSampleIdentifierOrNull()); if (values == null) { values = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); datasetFilter.put(ds.getSampleIdentifierOrNull(), values); } values.add(ds); } if (filterFor.equals("measured")) { BeanItemContainer<TestSampleBean> samplesContainer = new BeanItemContainer<TestSampleBean>( TestSampleBean.class); // List<Sample> allSamples = // datahandler.getOpenBisClient() // .getSamplesOfProjectBySearchService(projectIdentifier); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(id); for (Sample sample : allSamples) { checkedTestSamples.put(sample.getCode(), sample); if (sample.getSampleTypeCode().equals("Q_TEST_SAMPLE")) { // samplesContainer.addBean(new SampleBean(sample.getIdentifier(), sample.getCode(), // sample.getSampleTypeCode(), null, null, null, sample.getProperties(), null, // null)); Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(sample.getSampleTypeCode()); newBean.setSampleType(sampleProperties.get("Q_SAMPLE_TYPE")); newBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } for (Sample child : sample.getChildren()) { foundDataset = datasetFilter.get(child.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } } } else if (sample.getSampleTypeCode().equals("Q_MHC_LIGAND_EXTRACT")) { // samplesContainer.addBean(new SampleBean(sample.getIdentifier(), sample.getCode(), // sample.getSampleTypeCode(), null, null, null, sample.getProperties(), null, // null)); Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(sample.getSampleTypeCode()); newBean.setSampleType(sampleProperties.get("Q_MHC_CLASS")); newBean.setAdditionalInfo(sampleProperties.get("Q_ANTIBODY")); newBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } for (Sample child : sample.getChildren()) { foundDataset = datasetFilter.get(child.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } } } } numberOfSamples = samplesContainer.size(); samples = samplesContainer; final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(samples); gpc.removeContainerProperty("id"); gpc.removeContainerProperty("type"); sampleGrid.setContainerDataSource(gpc); sampleGrid.setColumnReorderingAllowed(true); gpc.addGeneratedProperty("edit", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "Edit"; } @Override public Class<String> getType() { return String.class; } }); sampleGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedExp = (TestSampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); sampleGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedSample = (TestSampleBean) selected.getBean(); Window subWindow = new Window("Edit Metadata"); changeMetadata.updateUI(selectedSample.getId(), selectedSample.getType()); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); subWindow.setContent(subContent); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setIcon(FontAwesome.PENCIL); subWindow.setHeight("75%"); subWindow.setResizable(false); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(typeString, idString, filterString); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } })); sampleGrid.getColumn("edit").setHeaderCaption(""); sampleGrid.getColumn("edit").setWidth(70); sampleGrid.setColumnOrder("edit", "secondaryName", "sampleType", "code", "properties", "additionalInfo", "externalDB"); helpers.GridFunctions.addColumnFilters(sampleGrid, gpc); numberOfSamples = samplesContainer.size(); sampleGrid.setCaption("Measured Samples"); this.datasetTable.setCaption("Raw Data"); numberOfDatasets = retrievedDatasets.size(); this.datasetTable.setPageLength(Math.max(3, Math.min(numberOfDatasets, 10))); // sampleGrid.setHeightMode(HeightMode.ROW); // sampleGrid.setHeightByRows(numberOfSamples); } else if (filterFor.equals("results")) { BeanItemContainer<TestSampleBean> samplesContainer = new BeanItemContainer<TestSampleBean>( TestSampleBean.class); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(projectIdentifier); for (Sample sample : allSamples) { checkedTestSamples.put(sample.getCode(), sample); if (!sample.getSampleTypeCode().equals("Q_TEST_SAMPLE") && !sample.getSampleTypeCode().equals("Q_MICROARRAY_RUN") && !sample.getSampleTypeCode().equals("Q_MS_RUN") && !sample.getSampleTypeCode().equals("Q_BIOLOGICAL_SAMPLE") && !sample.getSampleTypeCode().equals("Q_BIOLOGICAL_ENTITY") && !sample.getSampleTypeCode().equals("Q_NGS_SINGLE_SAMPLE_RUN")) { Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(prettyNameMapper.getPrettyName(sample.getSampleTypeCode())); newBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : foundDataset) { // we don't want to show project data or log files in the results tab if (ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) { if (ds.getProperties().get("Q_ATTACHMENT_TYPE").equals("INFORMATION")) { continue; } else { retrievedDatasets.add(ds); } } else if (ds.getDataSetTypeCode().contains("LOGS")) { continue; } else { retrievedDatasets.add(ds); } } // retrievedDatasets.addAll(foundDataset); } } } // numberOfSamples = samplesContainer.size(); samples = samplesContainer; final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(samples); gpc.removeContainerProperty("id"); gpc.removeContainerProperty("sampleType"); sampleGrid.setContainerDataSource(gpc); sampleGrid.setColumnReorderingAllowed(true); sampleGrid.setColumnOrder("secondaryName", "type", "code", "properties"); numberOfSamples = samplesContainer.size(); // sampleGrid.setHeightMode(HeightMode.ROW); // sampleGrid.setHeightByRows(numberOfSamples); sampleGrid.setCaption("Workflow Runs"); helpers.GridFunctions.addColumnFilters(sampleGrid, gpc); this.datasetTable.setCaption("Result Files"); datasetTable.setColumnHeader("Sample", "Workflow Run"); sampleGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedExp = (TestSampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); numberOfDatasets = retrievedDatasets.size(); this.datasetTable.setPageLength(Math.max(3, Math.min(numberOfDatasets, 10))); } break; case "experiment": String experimentIdentifier = id; retrievedDatasets = datahandler.getOpenBisClient() .getDataSetsOfExperimentByCodeWithSearchCriteria(experimentIdentifier); break; case "sample": String sampleIdentifier = id; String sampleCode = sampleIdentifier.split("/")[2]; retrievedDatasets = datahandler.getOpenBisClient().getDataSetsOfSample(sampleCode); break; default: retrievedDatasets = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); break; } BeanItemContainer<DatasetBean> forExport = new BeanItemContainer(DatasetBean.class); numberOfDatasets = retrievedDatasets.size(); if (numberOfDatasets == 0 & filterFor.equals("measured")) { descriptionLabel = new Label(String.format( "This project contains %s measured samples for which %s raw data dataset(s) have been registered.", numberOfSamples, 0), ContentMode.HTML); helpers.Utils.Notification("No raw data available.", "No raw data is available for this project. Please contact the project manager if this is not expected.", "warning"); } else if (numberOfDatasets == 0 & filterFor.equals("results")) { descriptionLabel = new Label(String.format("This project contains %s result datasets.", 0), ContentMode.HTML); helpers.Utils.Notification("No results available.", "No result data is available for this project. Please contact the project manager if this is not expected.", "warning"); } else { Map<String, String> samples = new HashMap<String, String>(); // project same for all datasets String projectCode = retrievedDatasets.get(0).getExperimentIdentifier().split("/")[2]; for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet dataset : retrievedDatasets) { samples.put(dataset.getCode(), dataset.getSampleIdentifierOrNull().split("/")[2]); } List<DatasetBean> dsBeans = datahandler.queryDatasetsForFolderStructure(retrievedDatasets); for (DatasetBean d : dsBeans) { Date date = d.getRegistrationDate(); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); String dateString = sd.format(date); // Timestamp ts = Timestamp.valueOf(dateString); String sampleID = samples.get(d.getCode()); forExport.addBean(d); Sample dsSample = checkedTestSamples.get(sampleID); String secNameDS = d.getProperties().get("Q_SECONDARY_NAME"); String secName = datahandler.getSecondaryName(dsSample, secNameDS); registerDatasetInTable(d, datasetContainer, projectCode, sampleID, dateString, null, secName); } if (filterFor.equals("measured")) { descriptionLabel = new Label(String.format( "This project contains %s measured samples for which %s raw data dataset(s) have been registered.", numberOfSamples, dsBeans.size()), ContentMode.HTML); } else if (filterFor.equals("results")) { descriptionLabel = new Label( String.format("This project contains %s result datasets.", dsBeans.size()), ContentMode.HTML); } } this.setContainerDataSource(datasetContainer); if (fileDownloaderData != null) this.exportData.removeExtension(fileDownloaderData); StreamResource srData = Utils.getTSVStream(Utils.containerToString(forExport), String.format("%s_%s_", id.substring(1).replace("/", "_"), datasetTable.getCaption().replace(" ", "_"))); fileDownloaderData = new FileDownloader(srData); fileDownloaderData.extend(exportData); if (fileDownloaderSamples != null) this.exportSamples.removeExtension(fileDownloaderSamples); StreamResource srSamples = Utils.getTSVStream(Utils.containerToString(samples), String.format("%s_%s_", id.substring(1).replace("/", "_"), sampleGrid.getCaption().replaceAll(" ", "_"))); fileDownloaderSamples = new FileDownloader(srSamples); fileDownloaderSamples.extend(exportSamples); } catch (Exception e) { e.printStackTrace(); LOGGER.error(String.format("getting dataset failed for dataset %s %s", type, id), e.getStackTrace()); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java
License:Open Source License
private void initUI() { status = new VerticalLayout(); status.setWidth(100.0f, Unit.PERCENTAGE); status.setMargin(new MarginInfo(true, false, false, true)); status.setSpacing(true);/*from w w w . jav a 2 s . com*/ // status.setSizeFull(); VerticalLayout projectStatus = new VerticalLayout(); projectStatus.setMargin(new MarginInfo(true, false, true, true)); projectStatus.setSpacing(true); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); // experiments.setHeightMode(HeightMode.ROW); status.addComponent(experiments); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(0f); status.addComponent(progressBar); projectStatus.addComponent(status); this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.85f, Unit.PIXELS); this.setCompositionRoot(projectStatus); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
/** * //from ww w.ja v a 2 s .c o m * @param statusValues * @return */ public VerticalLayout initProjectStatus() { status = new VerticalLayout(); status.setWidth(100.0f, Unit.PERCENTAGE); status.setMargin(new MarginInfo(true, false, true, true)); status.setSpacing(true); // status.setCaption("Project Status"); // status.setIcon(FontAwesome.CHECK_SQUARE); status.setSizeFull(); VerticalLayout projectStatus = new VerticalLayout(); projectStatus.setCaption("Status"); projectStatus.setMargin(new MarginInfo(true, false, true, true)); projectStatus.setSpacing(true); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); status.addComponent(experiments); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(0f); status.addComponent(progressBar); projectStatus.addComponent(status); return projectStatus; }