Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/qbicsoftware/qnavigator
Browse files Browse the repository at this point in the history
 into development
  • Loading branch information
christopher-mohr committed Sep 7, 2017
2 parents 8b84bd4 + 754f44f commit d52941a
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 129 deletions.
Binary file modified QBiCMainPortlet/WebContent/WEB-INF/lib/XMLManager.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions QBiCMainPortlet/src/controllers/WorkflowViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.commons.lang.NotImplementedException;

import parser.XMLParser;
import properties.Factor;
import properties.Property;
import submitter.SubmitFailedException;
import submitter.Submitter;
import submitter.Workflow;
Expand Down Expand Up @@ -370,13 +370,13 @@ private void mapExperimentalProperties(String id, List<String> fileNames) {
secondaryName += "1";
secondaryNames.add(secondaryName);
row.append(secondaryName);
List<Factor> factors = new ArrayList<Factor>();
List<Property> properties = new ArrayList<Property>();
try {
factors = p.getFactorsFromXML(xml);
properties = p.getAllPropertiesFromXML(xml);
} catch (JAXBException e) {
e.printStackTrace();
}
for (Factor f : factors) {
for (Property f : properties) {
factorNames.add(f.getLabel());
String val = f.getValue();
if (f.hasUnit())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/*******************************************************************************
* 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 License, or
* (at your option) any later version.
* 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
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License along with this program. If
* not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package de.uni_tuebingen.qbic.qbicmainportlet;

Expand All @@ -29,9 +27,9 @@

import model.PropertyBean;
import parser.XMLParser;
import properties.Factor;
import properties.Property;
import properties.PropertyType;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.VocabularyTerm;

import com.vaadin.data.fieldgroup.FieldGroup;
Expand All @@ -55,13 +53,13 @@ public class ChangeExperimentMetadataComponent extends CustomComponent {
private DataHandler datahandler;
private String resourceUrl;
private State state;
private VerticalLayout properties;
private VerticalLayout propLayout;

private FormLayout form;
private FieldGroup fieldGroup;
VerticalLayout vert;
String id;
private List<PropertyType> completeProperties;
private List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType> completeProperties;
private Map<String, String> assignedProperties;

public ChangeExperimentMetadataComponent(DataHandler dh, State state, String resourceurl) {
Expand All @@ -75,56 +73,67 @@ public ChangeExperimentMetadataComponent(DataHandler dh, State state, String res
}

private void initUI() {
properties = new VerticalLayout();
properties.setWidth(100.0f, Unit.PERCENTAGE);
properties.setMargin(new MarginInfo(true, false, true, true));
properties.setSpacing(true);
propLayout = new VerticalLayout();
propLayout.setWidth(100.0f, Unit.PERCENTAGE);
propLayout.setMargin(new MarginInfo(true, false, true, true));
propLayout.setSpacing(true);

this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS);
this.setCompositionRoot(properties);
this.setCompositionRoot(propLayout);
}

public void updateUI(final String id, String type) {
properties.removeAllComponents();
propLayout.removeAllComponents();
Button saveButton = new Button("Submit Changes");
saveButton.setStyleName(ValoTheme.BUTTON_FRIENDLY);

completeProperties =
datahandler.getOpenBisClient().listPropertiesForType(
datahandler.getOpenBisClient().getExperimentTypeByString(type));
completeProperties = datahandler.getOpenBisClient()
.listPropertiesForType(datahandler.getOpenBisClient().getExperimentTypeByString(type));

assignedProperties =
datahandler.getOpenBisClient().getExperimentById2(id).get(0).getProperties();

saveButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
HashMap<String, Object> properties = new HashMap<String, Object>();
HashMap<String, Object> props = new HashMap<String, Object>();
Collection<Field<?>> registeredFields = fieldGroup.getFields();
XMLParser xmlParser = new XMLParser();

List<Factor> factors = new ArrayList<Factor>();
List<Property> factors = new ArrayList<Property>();

boolean qpropertiesDefined = false;

for (Field<?> field : registeredFields) {
if (field.getDescription().equals("Q_PROPERTIES")) {
TextField tf = (TextField) field;
qpropertiesDefined = true;
Factor f = new Factor(field.getCaption(), (String) field.getValue());
String label = tf.getCaption();
String val = (String) tf.getValue();
String[] splt = label.split(" in ");
Property f = null;
PropertyType type = (PropertyType) tf.getData();
if (splt.length > 1) {
label = splt[0];
properties.Unit unit = properties.Unit.valueOf(splt[1]);
f = new Property(label, val, unit, type);
} else {
f = new Property(label, val, type);
}
factors.add(f);
}

else {
properties.put(field.getDescription(), field.getValue());
props.put(field.getDescription(), field.getValue());
}
}

if (qpropertiesDefined) {
String qProperties = "";

try {
qProperties = xmlParser.toString(xmlParser.createXMLFromFactors(factors));
properties.put("Q_PROPERTIES", qProperties);
qProperties = xmlParser.toString(xmlParser.createXMLFromProperties(factors));
props.put("Q_PROPERTIES", qProperties);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand All @@ -135,7 +144,7 @@ public void buttonClick(final ClickEvent event) {
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("user", LiferayAndVaadinUtils.getUser().getScreenName());
parameters.put("identifier", id);
parameters.put("properties", properties);
parameters.put("properties", props);

datahandler.getOpenBisClient().triggerIngestionService("update-experiment-metadata",
parameters);
Expand All @@ -145,21 +154,18 @@ public void buttonClick(final ClickEvent event) {
}
});
buildFormLayout();
properties
.addComponent(new Label(
String
.format(
"This view shows metadata connected to this experiment and can be used to change the corresponding values. \nIdentifier: %s",
id), Label.CONTENT_PREFORMATTED));

properties.addComponent(this.form);
properties.addComponent(saveButton);
propLayout.addComponent(new Label(String.format(
"This view shows metadata connected to this experiment and can be used to change the corresponding values. \nIdentifier: %s",
id), Label.CONTENT_PREFORMATTED));

propLayout.addComponent(this.form);
propLayout.addComponent(saveButton);
}

private Map<String, PropertyBean> getControlledVocabularies() {
Map<String, PropertyBean> controlledVocabularies = new HashMap<String, PropertyBean>();

for (PropertyType p : completeProperties) {
for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType p : completeProperties) {
if (p instanceof ControlledVocabularyPropertyType) {

ControlledVocabularyPropertyType controlled_vocab = (ControlledVocabularyPropertyType) p;
Expand All @@ -184,34 +190,34 @@ private Map<String, PropertyBean> getControlledVocabularies() {

private Map<String, PropertyBean> getProperties() {
Map<String, PropertyBean> properties = new HashMap<String, PropertyBean>();
for (PropertyType p : completeProperties) {
for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType p : completeProperties) {
if (p.getDataType().toString().equals("XML")) {
continue;
} else if (assignedProperties.keySet().contains(p.getCode())) {
properties.put(p.getCode(), new PropertyBean(p.getLabel(), p.getCode(), p.getDescription(),
assignedProperties.get(p.getCode())));
} else {
properties.put(p.getCode(), new PropertyBean(p.getLabel(), p.getCode(), p.getDescription(),
""));
properties.put(p.getCode(),
new PropertyBean(p.getLabel(), p.getCode(), p.getDescription(), ""));
}
}
return properties;

}

private List<Factor> getXMLProperties() {
private List<Property> getXMLProperties() {
XMLParser xmlParser = new XMLParser();
List<Factor> factors = new ArrayList<Factor>();
List<Property> properties = new ArrayList<Property>();

if (assignedProperties.containsKey("Q_PROPERTIES")) {
try {
factors = xmlParser.getFactorsFromXML(assignedProperties.get("Q_PROPERTIES"));
properties = xmlParser.getAllPropertiesFromXML(assignedProperties.get("Q_PROPERTIES"));
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return factors;
return properties;
}

private void buildFormLayout() {
Expand All @@ -220,12 +226,18 @@ private void buildFormLayout() {

Map<String, PropertyBean> controlledVocabularies = getControlledVocabularies();
Map<String, PropertyBean> properties = getProperties();
List<Factor> factors = getXMLProperties();

for (Factor f : factors) {
TextField tf = new TextField(f.getLabel());
fieldGroup.bind(tf, f.getLabel());
tf.setCaption(f.getLabel());
List<Property> xmlProps = getXMLProperties();

for (Property f : xmlProps) {
PropertyType type = f.getType();

String label = f.getLabel();
if (f.hasUnit())
label += " in " + f.getUnit();
TextField tf = new TextField(label);
tf.setData(type);//save property type for later, when it is written back
fieldGroup.bind(tf, label);
tf.setCaption(label);
tf.setDescription("Q_PROPERTIES");
tf.setValue((String) f.getValue());
form2.addComponent(tf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import logging.Log4j2Logger;
import logging.Logger;
import model.ProjectBean;
import properties.Factor;
import properties.Property;

import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.server.Page;
Expand Down Expand Up @@ -95,7 +95,7 @@ public void buttonClick(final ClickEvent event) {
HashMap<String, Object> parameters = new HashMap<String, Object>();
Collection<Field<?>> registeredFields = fieldGroup.getFields();

List<Factor> factors = new ArrayList<Factor>();
// List<Property> factors = new ArrayList<Property>();

for (Field<?> field : registeredFields) {
parameters.put("description", field.getValue());
Expand Down
Loading

0 comments on commit d52941a

Please sign in to comment.