diff --git a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/xls/export/helper/XLSVocabularyExportHelper.java b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/xls/export/helper/XLSVocabularyExportHelper.java index 457a39ad488eea89e5061d27e1b7ae9cbe58bbfd..39cc75f1741d2108928dc3b954514f755bfa1d10 100644 --- a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/xls/export/helper/XLSVocabularyExportHelper.java +++ b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/xls/export/helper/XLSVocabularyExportHelper.java @@ -15,6 +15,8 @@ */ package ch.ethz.sis.openbis.generic.server.xls.export.helper; +import static ch.ethz.sis.openbis.generic.server.xls.export.Attribute.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -115,7 +117,7 @@ public class XLSVocabularyExportHelper extends AbstractXLSExportHelper<IEntityTy { if (FieldType.valueOf(attribute.get(FIELD_TYPE_KEY)) == FieldType.ATTRIBUTE) { - return Attribute.valueOf(attribute.get(FIELD_ID_KEY)).getName(); + return valueOf(attribute.get(FIELD_ID_KEY)).getName(); } else { throw new IllegalArgumentException(); @@ -126,7 +128,7 @@ public class XLSVocabularyExportHelper extends AbstractXLSExportHelper<IEntityTy .toArray(Attribute[]::new); final Set<Attribute> selectedAttributes = selectedExportAttributes.stream() .filter(map -> map.get(FIELD_TYPE_KEY).equals(FieldType.ATTRIBUTE.toString())) - .map(map -> Attribute.valueOf(map.get(FIELD_ID_KEY))) + .map(map -> valueOf(map.get(FIELD_ID_KEY))) .collect(Collectors.toCollection(() -> EnumSet.noneOf(Attribute.class))); final Stream<String> requiredForImportAttributeNameStream = compatibleWithImport ? Arrays.stream(requiredForImportAttributes) @@ -152,7 +154,7 @@ public class XLSVocabularyExportHelper extends AbstractXLSExportHelper<IEntityTy { if (FieldType.valueOf(field.get(FIELD_TYPE_KEY)) == FieldType.ATTRIBUTE) { - return getAttributeValue(vocabulary, Attribute.valueOf(field.get(FIELD_ID_KEY))); + return getAttributeValue(vocabulary, valueOf(field.get(FIELD_ID_KEY))); } else { throw new IllegalArgumentException(); @@ -188,7 +190,7 @@ public class XLSVocabularyExportHelper extends AbstractXLSExportHelper<IEntityTy protected Attribute[] getAttributes() { - return new Attribute[] { Attribute.VERSION, Attribute.CODE, Attribute.DESCRIPTION }; + return new Attribute[] { VERSION, CODE, DESCRIPTION, REGISTRATOR, REGISTRATION_DATE, MODIFICATION_DATE }; } protected String getAttributeValue(final Vocabulary vocabulary, final Attribute attribute) @@ -207,6 +209,18 @@ public class XLSVocabularyExportHelper extends AbstractXLSExportHelper<IEntityTy { return vocabulary.getDescription(); } + case REGISTRATOR: + { + return vocabulary.getRegistrator().getUserId(); + } + case REGISTRATION_DATE: + { + return DATE_FORMAT.format(vocabulary.getRegistrationDate()); + } + case MODIFICATION_DATE: + { + return DATE_FORMAT.format(vocabulary.getModificationDate()); + } default: { return null; diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/VocabularyExpectations.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/VocabularyExpectations.java index c3bd23e763d5fa549e9b4a5a787b48860751ca23..2d0130a5b2dae3fe501983b4755cd43ae7fcbdbc 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/VocabularyExpectations.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/VocabularyExpectations.java @@ -16,7 +16,9 @@ package ch.ethz.sis.openbis.generic.server.xls.export; import java.util.Arrays; +import java.util.Calendar; import java.util.Collections; +import java.util.Date; import java.util.List; import org.jmock.Expectations; @@ -25,6 +27,7 @@ import org.jmock.lib.action.CustomAction; import ch.ethz.sis.openbis.generic.asapi.v3.IApplicationServerApi; import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.person.Person; import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.Vocabulary; import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.VocabularyTerm; import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.fetchoptions.VocabularyFetchOptions; @@ -37,6 +40,16 @@ class VocabularyExpectations extends Expectations public VocabularyExpectations(final IApplicationServerApi api, final boolean exportReferred) { + final Calendar calendar = Calendar.getInstance(); + calendar.set(2023, Calendar.MARCH, 10, 17, 23, 44); + final Date registrationDate = calendar.getTime(); + + calendar.set(2023, Calendar.MARCH, 11, 17, 23, 44); + final Date modificationDate = calendar.getTime(); + + final Person registrator = new Person(); + registrator.setUserId("system"); + allowing(api).getVocabularies(with(XLSExportTest.SESSION_TOKEN), with(new CollectionMatcher<>( Collections.singletonList(new VocabularyPermId("ANTIBODY.DETECTION")))), with(any(VocabularyFetchOptions.class))); @@ -48,11 +61,15 @@ class VocabularyExpectations extends Expectations public Object invoke(final Invocation invocation) throws Throwable { final VocabularyFetchOptions fetchOptions = (VocabularyFetchOptions) invocation.getParameter(2); + fetchOptions.withRegistrator(); final Vocabulary vocabulary = new Vocabulary(); vocabulary.setFetchOptions(fetchOptions); vocabulary.setCode("ANTIBODY.DETECTION"); vocabulary.setDescription("Protein detection system"); + vocabulary.setRegistrator(registrator); + vocabulary.setRegistrationDate(registrationDate); + vocabulary.setModificationDate(modificationDate); vocabulary.setTerms(getVocabularyTerms(fetchOptions)); diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/resources/export-vocabulary.xlsx b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/resources/export-vocabulary.xlsx index fc3e697b1d6025a5f1cc80308b333a37aee525f6..59b389334173acaf4b8db18f10be6908c067c6f9 100644 Binary files a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/resources/export-vocabulary.xlsx and b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/generic/server/xls/export/resources/export-vocabulary.xlsx differ