Skip to content
Snippets Groups Projects
Commit 72de4724 authored by vkovtun's avatar vkovtun
Browse files

SSDM-13693: Fixing the issue. Added special checks for existence of sample/experiment attributes.

parent 801e4b01
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -80,7 +80,7 @@ public abstract class AbstractXLSEntityExportHelper<ENTITY extends IPermIdHolder
warnings.addAll(addRow(rowNumber++, true, typeExportableKind, typePermId, entityTypeName));
warnings.addAll(addRow(rowNumber++, false, typeExportableKind, typePermId, typePermId));
final Attribute[] possibleAttributes = getAttributes(entry.getValue().get(0));
final Attribute[] possibleAttributes = getAttributes(entry.getValue());
final List<PropertyType> propertyTypes = entry.getKey().getPropertyAssignments().stream().map(PropertyAssignment::getPropertyType)
.collect(Collectors.toList());
if (entityTypeExportFieldsMap == null || entityTypeExportFieldsMap.isEmpty() ||
......@@ -221,7 +221,7 @@ public abstract class AbstractXLSEntityExportHelper<ENTITY extends IPermIdHolder
protected abstract Function<ENTITY, ENTITY_TYPE> getTypeFunction();
protected abstract Attribute[] getAttributes(final ENTITY entity);
protected abstract Attribute[] getAttributes(final Collection<ENTITY> entities);
protected abstract String getAttributeValue(final ENTITY entity, final Attribute attribute);
......
......@@ -42,9 +42,12 @@ import org.apache.poi.ss.usermodel.Workbook;
import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSet;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.PhysicalData;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.Person;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.Sample;
import ch.ethz.sis.openbis.generic.server.xls.export.Attribute;
import ch.ethz.sis.openbis.generic.server.xls.export.ExportableKind;
import ch.ethz.sis.openbis.generic.server.xls.export.XLSExport;
......@@ -116,10 +119,21 @@ public class XLSDataSetExportHelper extends AbstractXLSEntityExportHelper<DataSe
}
@Override
protected Attribute[] getAttributes(final DataSet dataSet)
protected Attribute[] getAttributes(final Collection<DataSet> dataSets)
{
return new Attribute[] { PERM_ID, CODE, ARCHIVING_STATUS, PRESENT_IN_ARCHIVE, STORAGE_CONFIRMATION,
dataSet.getSample() != null ? SAMPLE : EXPERIMENT, PARENTS, CHILDREN, REGISTRATOR, REGISTRATION_DATE, MODIFIER, MODIFICATION_DATE };
final boolean includeSample = dataSets.stream().anyMatch(dataSet -> dataSet.getSample() != null);
final boolean includeExperiment = dataSets.stream().anyMatch(dataSet -> dataSet.getSample() == null && dataSet.getExperiment() != null);
return Stream.concat(
Stream.concat(
Stream.of(PERM_ID, CODE, ARCHIVING_STATUS, PRESENT_IN_ARCHIVE, STORAGE_CONFIRMATION),
Stream.ofNullable(includeSample ? SAMPLE : null)
),
Stream.concat(
Stream.ofNullable(includeExperiment ? EXPERIMENT : null),
Stream.of(PARENTS, CHILDREN, REGISTRATOR, REGISTRATION_DATE, MODIFIER, MODIFICATION_DATE)
)
).toArray(Attribute[]::new);
}
@Override
......@@ -133,15 +147,18 @@ public class XLSDataSetExportHelper extends AbstractXLSEntityExportHelper<DataSe
}
case ARCHIVING_STATUS:
{
return dataSet.getPhysicalData().getStatus().toString();
final PhysicalData physicalData = dataSet.getPhysicalData();
return physicalData != null ? physicalData.getStatus().toString() : null;
}
case PRESENT_IN_ARCHIVE:
{
return dataSet.getPhysicalData().isPresentInArchive().toString().toUpperCase();
final PhysicalData physicalData = dataSet.getPhysicalData();
return physicalData != null ? physicalData.isPresentInArchive().toString().toUpperCase() : null;
}
case STORAGE_CONFIRMATION:
{
return dataSet.getPhysicalData().isStorageConfirmation().toString().toUpperCase();
final PhysicalData physicalData = dataSet.getPhysicalData();
return physicalData != null ? physicalData.isStorageConfirmation().toString().toUpperCase() : null;
}
case CODE:
{
......@@ -149,11 +166,14 @@ public class XLSDataSetExportHelper extends AbstractXLSEntityExportHelper<DataSe
}
case SAMPLE:
{
return dataSet.getSample().getIdentifier().getIdentifier();
final Sample sample = dataSet.getSample();
return sample != null ? sample.getIdentifier().getIdentifier() : null;
}
case EXPERIMENT:
{
return dataSet.getExperiment().getIdentifier().getIdentifier();
final Sample sample = dataSet.getSample();
final Experiment experiment = dataSet.getExperiment();
return sample == null && experiment != null ? experiment.getIdentifier().getIdentifier() : null;
}
case REGISTRATOR:
{
......
......@@ -51,7 +51,7 @@ public class XLSExperimentExportHelper extends AbstractXLSEntityExportHelper<Exp
}
@Override
protected Attribute[] getAttributes(final Experiment entity)
protected Attribute[] getAttributes(final Collection<Experiment> entities)
{
return new Attribute[] { PERM_ID, IDENTIFIER, CODE, PROJECT, REGISTRATOR, REGISTRATION_DATE, MODIFIER, MODIFICATION_DATE };
}
......
......@@ -39,11 +39,14 @@ import java.util.stream.Collectors;
import org.apache.poi.ss.usermodel.Workbook;
import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.Person;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.Project;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.Sample;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.SampleType;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleFetchOptions;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.SamplePermId;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space;
import ch.ethz.sis.openbis.generic.server.xls.export.Attribute;
import ch.ethz.sis.openbis.generic.server.xls.export.ExportableKind;
......@@ -86,7 +89,7 @@ public class XLSSampleExportHelper extends AbstractXLSEntityExportHelper<Sample,
}
@Override
protected Attribute[] getAttributes(final Sample entity)
protected Attribute[] getAttributes(final Collection<Sample> entities)
{
return new Attribute[] { $, AUTO_GENERATE_CODE, PERM_ID, IDENTIFIER, CODE, SPACE, PROJECT, EXPERIMENT, PARENTS, CHILDREN,
REGISTRATOR, REGISTRATION_DATE, MODIFIER, MODIFICATION_DATE };
......@@ -129,15 +132,18 @@ public class XLSSampleExportHelper extends AbstractXLSEntityExportHelper<Sample,
}
case SPACE:
{
return sample.getSpace() != null ? sample.getSpace().getPermId().getPermId() : "";
final Space space = sample.getSpace();
return space != null ? space.getPermId().getPermId() : null;
}
case PROJECT:
{
return sample.getProject() != null ? sample.getProject().getIdentifier().getIdentifier() : "";
final Project project = sample.getProject();
return project != null ? project.getIdentifier().getIdentifier() : null;
}
case EXPERIMENT:
{
return sample.getExperiment() != null ? sample.getExperiment().getIdentifier().getIdentifier() : "";
final Experiment experiment = sample.getExperiment();
return experiment != null ? experiment.getIdentifier().getIdentifier() : null;
}
case PARENTS:
{
......@@ -171,10 +177,6 @@ public class XLSSampleExportHelper extends AbstractXLSEntityExportHelper<Sample,
final Date modificationDate = sample.getModificationDate();
return modificationDate != null ? DATE_FORMAT.format(modificationDate) : null;
}
case $:
{
return "";
}
case AUTO_GENERATE_CODE:
{
return "FALSE";
......
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