Skip to content
Snippets Groups Projects
Commit b660b717 authored by cramakri's avatar cramakri
Browse files

LMS-2102 Nicer formatting, fixed bugs.

SVN: 20298
parent 6df2949e
No related branches found
No related tags found
No related merge requests found
...@@ -247,6 +247,7 @@ public class DataSetMetadataPanel extends JPanel ...@@ -247,6 +247,7 @@ public class DataSetMetadataPanel extends JPanel
newDataSetInfo.getNewDataSetBuilder().getDataSetMetadata() newDataSetInfo.getNewDataSetBuilder().getDataSetMetadata()
.setDataSetTypeOrNull(dataSetType); .setDataSetTypeOrNull(dataSetType);
clientModel.notifyObserversOfChanges(newDataSetInfo);
} }
protected void updateFileLabel() protected void updateFileLabel()
......
...@@ -143,7 +143,13 @@ public class DataSetPropertiesPanel extends JPanel ...@@ -143,7 +143,13 @@ public class DataSetPropertiesPanel extends JPanel
NewDataSetMetadataDTO metadata = builder.getDataSetMetadata(); NewDataSetMetadataDTO metadata = builder.getDataSetMetadata();
Map<String, String> props = metadata.getProperties(); Map<String, String> props = metadata.getProperties();
HashMap<String, String> newProps = new HashMap<String, String>(props); HashMap<String, String> newProps = new HashMap<String, String>(props);
newProps.put(propertyType.getCode(), text); if (null == text || text.trim().length() < 1)
{
newProps.remove(propertyType.getCode());
} else
{
newProps.put(propertyType.getCode(), text);
}
metadata.setProperties(newProps); metadata.setProperties(newProps);
clientModel.notifyObserversOfChanges(newDataSetInfo); clientModel.notifyObserversOfChanges(newDataSetInfo);
......
...@@ -46,6 +46,7 @@ import javax.swing.table.TableCellRenderer; ...@@ -46,6 +46,7 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.NotImplementedException;
import ch.systemsx.cisd.common.utilities.ITimeProvider; import ch.systemsx.cisd.common.utilities.ITimeProvider;
/** /**
...@@ -204,6 +205,7 @@ public class DataSetUploadClient extends AbstractSwingGUI ...@@ -204,6 +205,7 @@ public class DataSetUploadClient extends AbstractSwingGUI
{ {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
throw new NotImplementedException();
} }
}); });
...@@ -268,6 +270,9 @@ public class DataSetUploadClient extends AbstractSwingGUI ...@@ -268,6 +270,9 @@ public class DataSetUploadClient extends AbstractSwingGUI
fileTable.getColumnModel().getColumn(DataSetUploadTableModel.DATA_SET_OWNER_COLUMN); fileTable.getColumnModel().getColumn(DataSetUploadTableModel.DATA_SET_OWNER_COLUMN);
column.setPreferredWidth(320); column.setPreferredWidth(320);
column = fileTable.getColumnModel().getColumn(DataSetUploadTableModel.DATA_SET_TYPE_COLUMN);
column.setPreferredWidth(150);
column = column =
fileTable.getColumnModel().getColumn( fileTable.getColumnModel().getColumn(
DataSetUploadTableModel.DATA_SET_METADATA_COLUMN); DataSetUploadTableModel.DATA_SET_METADATA_COLUMN);
......
...@@ -18,15 +18,20 @@ package ch.systemsx.cisd.openbis.dss.client.api.gui; ...@@ -18,15 +18,20 @@ package ch.systemsx.cisd.openbis.dss.client.api.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.io.TransmissionSpeedCalculator; import ch.systemsx.cisd.common.io.TransmissionSpeedCalculator;
import ch.systemsx.cisd.common.utilities.ITimeProvider; import ch.systemsx.cisd.common.utilities.ITimeProvider;
import ch.systemsx.cisd.openbis.dss.client.api.v1.IDssComponent; import ch.systemsx.cisd.openbis.dss.client.api.v1.IDssComponent;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTOBuilder; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTOBuilder;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyTypeGroup;
/** /**
* @author Chandrasekhar Ramakrishnan * @author Chandrasekhar Ramakrishnan
...@@ -212,16 +217,16 @@ public class DataSetUploadClientModel ...@@ -212,16 +217,16 @@ public class DataSetUploadClientModel
return dataSetTypes; return dataSetTypes;
} }
public int getIndexOfDataSetType(String dataSetType) public int getIndexOfDataSetType(String dataSetTypeCode)
{ {
if (null == dataSetType) if (null == dataSetTypeCode)
{ {
return 0; return 0;
} }
for (int i = 0; i < dataSetTypes.size(); ++i) for (int i = 0; i < dataSetTypes.size(); ++i)
{ {
if (dataSetTypes.get(i).getCode().equals(dataSetType)) if (dataSetTypes.get(i).getCode().equals(dataSetTypeCode))
{ {
return i; return i;
} }
...@@ -239,10 +244,63 @@ public class DataSetUploadClientModel ...@@ -239,10 +244,63 @@ public class DataSetUploadClientModel
this.tableModel = tableModel; this.tableModel = tableModel;
} }
// Broadcasting Notifications /**
* Broadcast changes to observers.
*/
public void notifyObserversOfChanges(NewDataSetInfo changedInfo) public void notifyObserversOfChanges(NewDataSetInfo changedInfo)
{ {
tableModel.selectedRowDataChanged(); tableModel.selectedRowDataChanged();
} }
/**
* Clean the <var>newDataSetDTO</var> object. This means removing any properties that are not
* valid for the data set type.
*/
public NewDataSetDTO cleanNewDataSetDTO(NewDataSetDTO newDataSetDTO)
{
DataSetType dataSetType = tryDataSetType(newDataSetDTO.tryDataSetType());
if (null == dataSetType)
{
throw new UserFailureException("The new data set has no type");
}
HashSet<String> allPropertyCodes = new HashSet<String>();
for (PropertyTypeGroup group : dataSetType.getPropertyTypeGroups())
{
for (PropertyType propertyType : group.getPropertyTypes())
{
allPropertyCodes.add(propertyType.getCode());
}
}
HashSet<String> keys = new HashSet<String>(newDataSetDTO.getProperties().keySet());
for (String propertyTypeCode : keys)
{
if (false == allPropertyCodes.contains(propertyTypeCode))
{
newDataSetDTO.getProperties().remove(propertyTypeCode);
}
}
return newDataSetDTO;
}
private DataSetType tryDataSetType(String dataSetTypeCode)
{
if (null == dataSetTypeCode)
{
return null;
}
for (int i = 0; i < dataSetTypes.size(); ++i)
{
DataSetType type = dataSetTypes.get(i);
if (type.getCode().equals(dataSetTypeCode))
{
return type;
}
}
return null;
}
} }
...@@ -21,6 +21,7 @@ import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; ...@@ -21,6 +21,7 @@ import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.exceptions.FileExistsException; import ch.systemsx.cisd.common.exceptions.FileExistsException;
import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo; import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo;
import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo.Status; import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo.Status;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO;
/** /**
* DataSetUploadOperation represents a request to upload a data set to openBIS/dss. The upload * DataSetUploadOperation represents a request to upload a data set to openBIS/dss. The upload
...@@ -53,8 +54,10 @@ final class DataSetUploadOperation implements Runnable ...@@ -53,8 +54,10 @@ final class DataSetUploadOperation implements Runnable
{ {
newDataSetInfo.setStatus(Status.UPLOADING); newDataSetInfo.setStatus(Status.UPLOADING);
tableModel.fireChanged(newDataSetInfo, Status.UPLOADING); tableModel.fireChanged(newDataSetInfo, Status.UPLOADING);
clientModel.getDssComponent().putDataSet( NewDataSetDTO cleanDto =
newDataSetInfo.getNewDataSetBuilder().asNewDataSetDTO(), clientModel.cleanNewDataSetDTO(newDataSetInfo.getNewDataSetBuilder()
.asNewDataSetDTO());
clientModel.getDssComponent().putDataSet(cleanDto,
newDataSetInfo.getNewDataSetBuilder().getFile()); newDataSetInfo.getNewDataSetBuilder().getFile());
} }
newDataSetInfo.setStatus(Status.COMPLETED_UPLOAD); newDataSetInfo.setStatus(Status.COMPLETED_UPLOAD);
......
...@@ -36,6 +36,8 @@ import javax.swing.table.TableColumnModel; ...@@ -36,6 +36,8 @@ import javax.swing.table.TableColumnModel;
import ch.systemsx.cisd.base.namedthread.NamingThreadPoolExecutor; import ch.systemsx.cisd.base.namedthread.NamingThreadPoolExecutor;
import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo; import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo;
import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo.Status; import ch.systemsx.cisd.openbis.dss.client.api.gui.DataSetUploadClientModel.NewDataSetInfo.Status;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTO.DataSetOwner;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDataSetDTOBuilder;
/** /**
* The DataSetUploadClientModel manages the list of data sets to register, initiates uploads (which * The DataSetUploadClientModel manages the list of data sets to register, initiates uploads (which
...@@ -52,11 +54,13 @@ public class DataSetUploadTableModel extends AbstractTableModel ...@@ -52,11 +54,13 @@ public class DataSetUploadTableModel extends AbstractTableModel
// Constants for column order // Constants for column order
static final int DATA_SET_OWNER_COLUMN = 0; static final int DATA_SET_OWNER_COLUMN = 0;
static final int DATA_SET_METADATA_COLUMN = 1; static final int DATA_SET_TYPE_COLUMN = 1;
static final int DATA_SET_PATH_COLUMN = 2; static final int DATA_SET_METADATA_COLUMN = 2;
static final int UPLOAD_STATUS_COLUMN = 3; static final int DATA_SET_PATH_COLUMN = 3;
static final int UPLOAD_STATUS_COLUMN = 4;
private static ExecutorService executor = new NamingThreadPoolExecutor("Data Set Upload", 1, 1, private static ExecutorService executor = new NamingThreadPoolExecutor("Data Set Upload", 1, 1,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()).daemonize(); 0, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()).daemonize();
...@@ -138,6 +142,15 @@ public class DataSetUploadTableModel extends AbstractTableModel ...@@ -138,6 +142,15 @@ public class DataSetUploadTableModel extends AbstractTableModel
String identifier2 = info2.getNewDataSetBuilder().getDataSetOwnerIdentifier(); String identifier2 = info2.getNewDataSetBuilder().getDataSetOwnerIdentifier();
result = identifier1.compareTo(identifier2); result = identifier1.compareTo(identifier2);
break; break;
case DATA_SET_TYPE_COLUMN:
String type1 =
info1.getNewDataSetBuilder().getDataSetMetadata().tryDataSetType();
String type2 =
info2.getNewDataSetBuilder().getDataSetMetadata().tryDataSetType();
type1 = null == type1 ? "" : type1;
type2 = null == type2 ? "" : type2;
result = type1.compareTo(type2);
break;
case DATA_SET_PATH_COLUMN: case DATA_SET_PATH_COLUMN:
File file1 = info1.getNewDataSetBuilder().getFile(); File file1 = info1.getNewDataSetBuilder().getFile();
File file2 = info2.getNewDataSetBuilder().getFile(); File file2 = info2.getNewDataSetBuilder().getFile();
...@@ -194,7 +207,7 @@ public class DataSetUploadTableModel extends AbstractTableModel ...@@ -194,7 +207,7 @@ public class DataSetUploadTableModel extends AbstractTableModel
public int getColumnCount() public int getColumnCount()
{ {
return 4; return 5;
} }
public int getRowCount() public int getRowCount()
...@@ -215,6 +228,9 @@ public class DataSetUploadTableModel extends AbstractTableModel ...@@ -215,6 +228,9 @@ public class DataSetUploadTableModel extends AbstractTableModel
case DATA_SET_OWNER_COLUMN: case DATA_SET_OWNER_COLUMN:
name += " Owner"; name += " Owner";
break; break;
case DATA_SET_TYPE_COLUMN:
name += " Type";
break;
case DATA_SET_METADATA_COLUMN: case DATA_SET_METADATA_COLUMN:
name += " Metadata"; name += " Metadata";
break; break;
...@@ -231,20 +247,33 @@ public class DataSetUploadTableModel extends AbstractTableModel ...@@ -231,20 +247,33 @@ public class DataSetUploadTableModel extends AbstractTableModel
public Object getValueAt(int rowIndex, int columnIndex) public Object getValueAt(int rowIndex, int columnIndex)
{ {
NewDataSetInfo newDataSetInfo = newDataSetInfos.get(rowIndex); NewDataSetInfo newDataSetInfo = newDataSetInfos.get(rowIndex);
NewDataSetDTOBuilder builder = newDataSetInfo.getNewDataSetBuilder();
switch (columnIndex) switch (columnIndex)
{ {
case DATA_SET_OWNER_COLUMN: case DATA_SET_OWNER_COLUMN:
return newDataSetInfo.getNewDataSetBuilder().getDataSetOwner(); DataSetOwner owner = builder.getDataSetOwner();
return owner.getType() + ":" + untouchedStringOrEmpty(owner.getIdentifier());
case DATA_SET_TYPE_COLUMN:
return untouchedStringOrEmpty(builder.getDataSetMetadata().tryDataSetType());
case DATA_SET_METADATA_COLUMN: case DATA_SET_METADATA_COLUMN:
return newDataSetInfo.getNewDataSetBuilder().getDataSetMetadata(); return builder.getDataSetMetadata().getProperties();
case DATA_SET_PATH_COLUMN: case DATA_SET_PATH_COLUMN:
return newDataSetInfo.getNewDataSetBuilder().getFile(); File file = builder.getFile();
return (file == null) ? "" : file.getName();
case UPLOAD_STATUS_COLUMN: case UPLOAD_STATUS_COLUMN:
return newDataSetInfo; return newDataSetInfo;
} }
return null; return null;
} }
/**
* If aString is null, make it a string
*/
private String untouchedStringOrEmpty(String aString)
{
return (aString == null) ? "" : aString;
}
@Override @Override
public Class<?> getColumnClass(int c) public Class<?> getColumnClass(int c)
{ {
......
...@@ -53,7 +53,7 @@ public class UploadStatusTableCellRenderer implements TableCellRenderer ...@@ -53,7 +53,7 @@ public class UploadStatusTableCellRenderer implements TableCellRenderer
private final JPanel retryPanel = new JPanel(); private final JPanel retryPanel = new JPanel();
private final JLabel completedLabel = new JLabel("Finished"); private final JLabel completedLabel = new JLabel("Registered");
private final JPanel completedPanel = new JPanel(); private final JPanel completedPanel = new JPanel();
......
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