Skip to content
Snippets Groups Projects
Commit 9eb67019 authored by gpawel's avatar gpawel
Browse files

LMS-2300 - DataSetUploader: Scripts that modify the data set properties (data set information)

SVN: 23583
parent dbb964d2
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -229,6 +230,7 @@ public class DataSetMetadataPanel extends JPanel implements Observer
{
if (null == newDataSetInfo)
{
dataSetPanel.setText(EMPTY_FILE_SELECTION);
samplePanel.setText(EMPTY_FILE_SELECTION);
experimentPicker.setText(EMPTY_FILE_SELECTION);
updateFileLabel();
......@@ -652,11 +654,28 @@ public class DataSetMetadataPanel extends JPanel implements Observer
private void validateAndNotifyObserversOfChanges()
{
validationErrors.waitCard();
extractMetadata();
clientModel.validateNewDataSetInfoAndNotifyObservers(newDataSetInfo);
syncErrors();
validationErrors.showResult();
}
private void extractMetadata()
{
if (newDataSetInfo.getNewDataSetBuilder() != null
&& newDataSetInfo.getNewDataSetBuilder().getFile() != null)
{
Map<String, String> properties =
clientModel.getOpenBISService().extractMetadata(
newDataSetInfo.getNewDataSetBuilder().asNewDataSetDTO(),
newDataSetInfo.getNewDataSetBuilder().getFile());
newDataSetInfo.getNewDataSetBuilder().getDataSetMetadata()
.setUnmodifiableProperties(properties);
}
syncGui();
}
private void setOwnerType(DataSetOwnerType type)
{
if (null == newDataSetInfo)
......
......@@ -304,6 +304,7 @@ public class DataSetPropertiesPanel extends JPanel
{
String propertyValue = props.get(propertyTypeCode);
JComponent formField = formFields.get(propertyTypeCode);
formField.setEnabled(false == metadata.isUnmodifiableProperty(propertyTypeCode));
if (formField instanceof JTextField)
{
JTextField textField = (JTextField) formField;
......@@ -319,6 +320,10 @@ public class DataSetPropertiesPanel extends JPanel
comboBox.setSelectedIndex(i);
}
}
} else if (formField instanceof JCheckBox)
{
JCheckBox checkBox = (JCheckBox) formField;
checkBox.setSelected(Boolean.parseBoolean(propertyValue));
}
}
}
......
......@@ -200,4 +200,11 @@ public class VocabularyTermsComboBoxPanel extends JPanel implements Observer
.getSelectedItem()).term.getCode() : code;
fillComboBoxWithTerms(vocabulary.getTerms(), selectedCode);
}
@Override
public void setEnabled(boolean enabled)
{
comboBox.setEnabled(enabled);
button.setEnabled(enabled);
}
}
......@@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.dss.client.api.v1;
import java.io.File;
import java.util.List;
import java.util.Map;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.InvalidSessionException;
......@@ -154,6 +155,19 @@ public interface ISimpleOpenbisServiceFacade
public List<ValidationError> validateDataSet(NewDataSetDTO newDataset, File dataSetFile)
throws IllegalStateException, EnvironmentFailureException;
/**
* Extracts metadata from a file.
*
* @param newDataset The new data set that should be registered
* @param dataSetFile A file or folder containing the data
* @return Map of property name/value pairs.
* @throws IllegalStateException Thrown if the user has not yet been authenticated.
* @throws EnvironmentFailureException Thrown in cases where it is not possible to connect to
* the server.
*/
public Map<String, String> extractMetadata(NewDataSetDTO newDataset, File dataSetFile)
throws IllegalStateException, EnvironmentFailureException;
/**
* Checks whether the session is alive.
*
......
......@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ch.rinn.restrictions.Private;
import ch.systemsx.cisd.common.api.client.ServiceFinder;
......@@ -347,6 +348,12 @@ public class OpenbisServiceFacade implements IOpenbisServiceFacade
return dssComponent.validateDataSet(newDataset, dataSetFile);
}
public Map<String, String> extractMetadata(NewDataSetDTO newDataset, File dataSetFile)
throws IllegalStateException, EnvironmentFailureException
{
return dssComponent.extractMetadata(newDataset, dataSetFile);
}
public void checkSession() throws InvalidSessionException
{
dssComponent.checkSession();
......
......@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked;
......@@ -161,5 +162,7 @@ public class NewDataSetDTOBuilder
HashMap<String, String> otherProps =
new HashMap<String, String>(otherMetadata.getProperties());
dataSetMetadata.setProperties(otherProps);
dataSetMetadata.setUnmodifiableProperties(new HashSet<String>(otherMetadata
.getUnmodifiableProperties()));
}
}
......@@ -18,11 +18,14 @@ package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
......@@ -39,6 +42,8 @@ public class NewDataSetMetadataDTO implements Serializable
private final Map<String, String> properties = new HashMap<String, String>();
private final Set<String> unmodifiableProperties = new HashSet<String>();
private String dataSetTypeOrNull;
private final ArrayList<String> parentDataSetCodes = new ArrayList<String>();
......@@ -85,6 +90,14 @@ public class NewDataSetMetadataDTO implements Serializable
return properties;
}
/**
* The unmodifiable property types (as strings).
*/
public Collection<String> getUnmodifiableProperties()
{
return unmodifiableProperties;
}
public void setProperties(Map<String, String> props)
{
properties.clear();
......@@ -94,6 +107,26 @@ public class NewDataSetMetadataDTO implements Serializable
}
}
public void setUnmodifiableProperties(Set<String> props)
{
unmodifiableProperties.clear();
if (props != null)
{
unmodifiableProperties.addAll(props);
}
}
public void setUnmodifiableProperties(Map<String, String> props)
{
setProperties(props);
setUnmodifiableProperties(props.keySet());
}
public boolean isUnmodifiableProperty(String property)
{
return unmodifiableProperties.contains(property);
}
/**
* The codes of the parent data sets for this new data set. The list may be empty.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment