diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/HistoryTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/HistoryTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..a0bc2173263d48efd6cad293f54ef33adcfffbd1 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/HistoryTranslator.java @@ -0,0 +1,234 @@ +/* + * Copyright 2013 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.history; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.AbstractCachingTranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.Relations; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.IPersonTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.DataSetRelationType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.ExperimentRelationType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.PropertyHistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.RelationHistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.SampleRelationType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.dataset.DataSetPermId; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPermId; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.project.ProjectPermId; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.SamplePermId; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.space.SpacePermId; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityHistoryDAO; +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.dto.AbstractEntityPropertyHistoryPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetHistoryPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentHistoryPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationHolderDTO; +import ch.systemsx.cisd.openbis.generic.shared.dto.SampleHistoryPE; + +/** + * @author pkupczyk + */ +@Component +public class HistoryTranslator extends AbstractCachingTranslator<IEntityInformationHolderDTO, List<HistoryEntry>, HistoryEntryFetchOptions> implements + IHistoryTranslator +{ + + @Autowired + private IDAOFactory daoFactory; + + @Autowired + private IPersonTranslator personTranslator; + + @Override + protected List<HistoryEntry> createObject(TranslationContext context, IEntityInformationHolderDTO entity, HistoryEntryFetchOptions fetchOptions) + { + IEntityHistoryDAO historyDAO = daoFactory.getEntityPropertyHistoryDAO(); + List<AbstractEntityPropertyHistoryPE> peEntries = historyDAO.getPropertyHistory(entity.getEntityKind(), new TechId(entity.getId())); + List<HistoryEntry> entries = new ArrayList<HistoryEntry>(); + + for (AbstractEntityPropertyHistoryPE peEntry : peEntries) + { + HistoryEntry entry = null; + + if (peEntry.getEntityTypePropertyType() == null) + { + if (peEntry instanceof ExperimentHistoryPE) + { + entry = createRelationEntry(context, (ExperimentHistoryPE) peEntry, fetchOptions); + } else if (peEntry instanceof SampleHistoryPE) + { + entry = createRelationEntry(context, (SampleHistoryPE) peEntry, fetchOptions); + } else if (peEntry instanceof DataSetHistoryPE) + { + entry = createRelationEntry(context, (DataSetHistoryPE) peEntry, fetchOptions); + } else + { + throw new IllegalArgumentException("Unsupported entity history: " + peEntry.getClass().getName()); + } + } else + { + entry = createPropertyEntry(context, peEntry, fetchOptions); + } + + if (entry != null) + { + entry.setValidFrom(peEntry.getValidFromDate()); + entry.setValidTo(peEntry.getValidUntilDate()); + + if (fetchOptions.hasAuthor()) + { + entry.setAuthor(personTranslator.translate(context, peEntry.getAuthor(), fetchOptions.withAuthor())); + } + + entries.add(entry); + } + } + + return entries; + } + + private HistoryEntry createRelationEntry(TranslationContext context, ExperimentHistoryPE history, HistoryEntryFetchOptions fetchOptions) + { + RelationHistoryEntry entry = new RelationHistoryEntry(); + + if (history.getProject() != null) + { + entry.setRelationType(ExperimentRelationType.PROJECT); + entry.setRelatedObjectId(new ProjectPermId(history.getEntityPermId())); + } else if (history.getSample() != null) + { + entry.setRelationType(ExperimentRelationType.SAMPLE); + entry.setRelatedObjectId(new SamplePermId(history.getEntityPermId())); + } else if (history.getDataSet() != null) + { + entry.setRelationType(ExperimentRelationType.DATA_SET); + entry.setRelatedObjectId(new DataSetPermId(history.getEntityPermId())); + } else + { + entry = null; + } + + return entry; + } + + private HistoryEntry createRelationEntry(TranslationContext context, SampleHistoryPE history, HistoryEntryFetchOptions fetchOptions) + { + RelationHistoryEntry entry = new RelationHistoryEntry(); + + if (history.getSpace() != null) + { + entry.setRelationType(SampleRelationType.SPACE); + entry.setRelatedObjectId(new SpacePermId(history.getEntityPermId())); + } else if (history.getExperiment() != null) + { + entry.setRelationType(SampleRelationType.EXPERIMENT); + entry.setRelatedObjectId(new SamplePermId(history.getEntityPermId())); + } else if (history.getSample() != null) + { + switch (history.getRelationType()) + { + case PARENT: + entry.setRelationType(SampleRelationType.CHILD); + break; + case CHILD: + entry.setRelationType(SampleRelationType.PARENT); + break; + case CONTAINER: + entry.setRelationType(SampleRelationType.COMPONENT); + break; + case COMPONENT: + entry.setRelationType(SampleRelationType.CONTAINER); + break; + default: + throw new IllegalArgumentException("Unsupported relation type: " + history.getRelationType()); + } + entry.setRelatedObjectId(new SamplePermId(history.getEntityPermId())); + } else if (history.getDataSet() != null) + { + entry.setRelationType(SampleRelationType.DATA_SET); + entry.setRelatedObjectId(new DataSetPermId(history.getEntityPermId())); + } else + { + entry = null; + } + + return entry; + } + + private HistoryEntry createRelationEntry(TranslationContext context, DataSetHistoryPE history, HistoryEntryFetchOptions fetchOptions) + { + RelationHistoryEntry entry = new RelationHistoryEntry(); + + if (history.getExperiment() != null) + { + entry.setRelationType(DataSetRelationType.EXPERIMENT); + entry.setRelatedObjectId(new ExperimentPermId(history.getEntityPermId())); + } else if (history.getSample() != null) + { + entry.setRelationType(DataSetRelationType.SAMPLE); + entry.setRelatedObjectId(new SamplePermId(history.getEntityPermId())); + } else if (history.getDataSet() != null) + { + switch (history.getRelationType()) + { + case PARENT: + entry.setRelationType(DataSetRelationType.CHILD); + break; + case CHILD: + entry.setRelationType(DataSetRelationType.PARENT); + break; + case CONTAINER: + entry.setRelationType(DataSetRelationType.COMPONENT); + break; + case COMPONENT: + entry.setRelationType(DataSetRelationType.CONTAINER); + break; + default: + throw new IllegalArgumentException("Unsupported relation type: " + history.getRelationType()); + } + entry.setRelatedObjectId(new DataSetPermId(history.getEntityPermId())); + } else + { + entry = null; + } + + return entry; + } + + private HistoryEntry createPropertyEntry(TranslationContext context, AbstractEntityPropertyHistoryPE peEntry, + HistoryEntryFetchOptions fetchOptions) + { + PropertyHistoryEntry entry = new PropertyHistoryEntry(); + entry.setPropertyName(peEntry.getEntityTypePropertyType().getPropertyType().getCode()); + entry.setPropertyValue(peEntry.getValue()); + return entry; + } + + @Override + protected void updateObject(TranslationContext context, IEntityInformationHolderDTO entity, List<HistoryEntry> entries, Relations relations, + HistoryEntryFetchOptions fetchOptions) + { + } +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/IHistoryTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/IHistoryTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..34bcec863cf6cf5622b2d323ef2463993621e630 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/history/IHistoryTranslator.java @@ -0,0 +1,32 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.history; + +import java.util.List; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.ITranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; +import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationHolderDTO; + +/** + * @author pkupczyk + */ +public interface IHistoryTranslator extends ITranslator<IEntityInformationHolderDTO, List<HistoryEntry>, HistoryEntryFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/SampleTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/SampleTranslator.java index 109a7d6d920a835558830fe4f0836791086687f4..ce9e3c4902fca6ce2ca7026f179d8f825e20d130 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/SampleTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/SampleTranslator.java @@ -20,6 +20,7 @@ import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.attachment.IAttachmentTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.IDataSetTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.IExperimentTranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.history.IHistoryTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.material.IMaterialPropertyTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.IPersonTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.IPropertyTranslator; @@ -70,6 +71,9 @@ public class SampleTranslator extends AbstractCachingTranslator<SamplePE, Sample @Autowired private IDataSetTranslator dataSetTranslator; + @Autowired + private IHistoryTranslator historyTranslator; + @Override protected boolean shouldTranslate(TranslationContext context, SamplePE input, SampleFetchOptions fetchOptions) { @@ -198,6 +202,12 @@ public class SampleTranslator extends AbstractCachingTranslator<SamplePE, Sample result.setAttachments(attachmentTranslator.translate(context, samplePe, fetchOptions.withAttachments())); result.getFetchOptions().withAttachmentsUsing(fetchOptions.withAttachments()); } + + if (fetchOptions.hasHistory()) + { + result.setHistory(historyTranslator.translate(context, samplePe, fetchOptions.withHistory())); + result.getFetchOptions().withHistoryUsing(fetchOptions.withHistory()); + } } private class SampleExperimentRelation extends ToOneRelation<SamplePE, ExperimentPE, Experiment, ExperimentFetchOptions> diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/MapSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/MapSampleTest.java index 48fc7ddf72c931060e3cf44c7b09429ef49e695b..6b660906da6dfabd9374054035fed538d40adfb1 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/MapSampleTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/MapSampleTest.java @@ -37,11 +37,16 @@ import org.testng.annotations.Test; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.PropertyHistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.RelationHistoryEntry; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.SampleRelationType; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.material.Material; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project.Project; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.Sample; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.SampleCreation; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.SampleType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.SampleUpdate; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.tag.Tag; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.sample.SampleFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.tag.TagFetchOptions; @@ -1012,4 +1017,100 @@ public class MapSampleTest extends AbstractSampleTest assertTagsNotFetched(gene); } + @Test + public void testMapWithHistoryEmpty() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + SampleCreation creation = new SampleCreation(); + creation.setCode("SAMPLE_WITH_EMPTY_HISTORY"); + creation.setTypeId(new EntityTypePermId("CELL_PLATE")); + creation.setSpaceId(new SpacePermId("CISD")); + + SampleFetchOptions fetchOptions = new SampleFetchOptions(); + fetchOptions.withHistory(); + + List<SamplePermId> permIds = v3api.createSamples(sessionToken, Arrays.asList(creation)); + Map<ISampleId, Sample> map = v3api.mapSamples(sessionToken, permIds, fetchOptions); + + assertEquals(map.size(), 1); + Sample sample = map.get(permIds.get(0)); + assertEquals(sample.getHistory(), Collections.emptyList()); + + v3api.logout(sessionToken); + } + + @Test + public void testMapWithHistoryProperty() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + SampleCreation creation = new SampleCreation(); + creation.setCode("SAMPLE_WITH_PROPERTY_HISTORY"); + creation.setTypeId(new EntityTypePermId("CELL_PLATE")); + creation.setSpaceId(new SpacePermId("CISD")); + creation.setProperty("COMMENT", "comment1"); + + List<SamplePermId> permIds = v3api.createSamples(sessionToken, Arrays.asList(creation)); + + SampleUpdate update = new SampleUpdate(); + update.setSampleId(permIds.get(0)); + update.setProperty("COMMENT", "comment2"); + + v3api.updateSamples(sessionToken, Arrays.asList(update)); + + SampleFetchOptions fetchOptions = new SampleFetchOptions(); + fetchOptions.withHistory(); + + Map<ISampleId, Sample> map = v3api.mapSamples(sessionToken, permIds, fetchOptions); + + assertEquals(map.size(), 1); + Sample sample = map.get(permIds.get(0)); + + List<HistoryEntry> history = sample.getHistory(); + assertEquals(history.size(), 1); + + PropertyHistoryEntry entry = (PropertyHistoryEntry) history.get(0); + assertEquals(entry.getPropertyName(), "COMMENT"); + assertEquals(entry.getPropertyValue(), "comment1"); + + v3api.logout(sessionToken); + } + + @Test + public void testMapWithHistorySpace() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + SampleCreation creation = new SampleCreation(); + creation.setCode("SAMPLE_WITH_SPACE_HISTORY"); + creation.setTypeId(new EntityTypePermId("CELL_PLATE")); + creation.setSpaceId(new SpacePermId("CISD")); + + List<SamplePermId> permIds = v3api.createSamples(sessionToken, Arrays.asList(creation)); + + SampleUpdate update = new SampleUpdate(); + update.setSampleId(permIds.get(0)); + update.setSpaceId(new SpacePermId("TEST-SPACE")); + + v3api.updateSamples(sessionToken, Arrays.asList(update)); + + SampleFetchOptions fetchOptions = new SampleFetchOptions(); + fetchOptions.withHistory(); + + Map<ISampleId, Sample> map = v3api.mapSamples(sessionToken, permIds, fetchOptions); + + assertEquals(map.size(), 1); + Sample sample = map.get(permIds.get(0)); + + List<HistoryEntry> history = sample.getHistory(); + assertEquals(history.size(), 1); + + RelationHistoryEntry entry = (RelationHistoryEntry) history.get(0); + assertEquals(entry.getRelationType(), SampleRelationType.SPACE); + assertEquals(entry.getRelatedObjectId(), new SpacePermId("CISD")); + + v3api.logout(sessionToken); + } + } diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/dataset/DataSet.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/dataset/DataSet.java index 5b4f5df6a047b29eb5225f6ec788786563a3737f..d014d5c8425e84e1fd3f225a2b6a2b84edebde02 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/dataset/DataSet.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/dataset/DataSet.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSetType; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.ExternalData; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModificationDateHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModifierHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IParentChildrenHolder; @@ -88,6 +89,9 @@ public class DataSet implements Serializable, IParentChildrenHolder<DataSet>, IM @JsonProperty private DataSetType type; + @JsonProperty + private List<HistoryEntry> history; + @JsonProperty private Date modificationDate; @@ -333,6 +337,26 @@ public class DataSet implements Serializable, IParentChildrenHolder<DataSet>, IM this.type = type; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public List<HistoryEntry> getHistory() + { + if (getFetchOptions().hasHistory()) + { + return history; + } + else + { + throw new NotFetchedException("History have not been fetched."); + } + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setHistory(List<HistoryEntry> history) + { + this.history = history; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} @JsonIgnore @Override diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/experiment/Experiment.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/experiment/Experiment.java index 7ec4561fe90bddadbf51bb73f1c28fdf40804e81..29b05519fb17c5e4e39d743dd3cf7b9af03aaba4 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/experiment/Experiment.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/experiment/Experiment.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.attachment.Attachment; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IAttachmentsHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModificationDateHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModifierHolder; @@ -81,6 +82,9 @@ public class Experiment implements Serializable, IModifierHolder, IModificationD @JsonProperty private List<Sample> samples; + @JsonProperty + private List<HistoryEntry> history; + @JsonProperty private Map<String, String> properties; @@ -259,6 +263,26 @@ public class Experiment implements Serializable, IModifierHolder, IModificationD this.samples = samples; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public List<HistoryEntry> getHistory() + { + if (getFetchOptions().hasHistory()) + { + return history; + } + else + { + throw new NotFetchedException("History have not been fetched."); + } + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setHistory(List<HistoryEntry> history) + { + this.history = history; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} @JsonIgnore @Override diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/DataSetRelationType.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/DataSetRelationType.java new file mode 100644 index 0000000000000000000000000000000000000000..98f3331be2355e6c37150bd7747668b4cfdca7b1 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/DataSetRelationType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * @author pkupczyk + */ +@JsonObject("dto.entity.history.DataSetRelationType") +public enum DataSetRelationType implements IRelationType +{ + + EXPERIMENT, SAMPLE, PARENT, CHILD, CONTAINER, COMPONENT + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/ExperimentRelationType.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/ExperimentRelationType.java new file mode 100644 index 0000000000000000000000000000000000000000..a1063f925abae5136a9a99e248d4bfd3b4a3aebd --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/ExperimentRelationType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * @author pkupczyk + */ +@JsonObject("dto.entity.history.ExperimentRelationType") +public enum ExperimentRelationType implements IRelationType +{ + + PROJECT, SAMPLE, DATA_SET + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/HistoryEntry.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/HistoryEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..c4f575ab6a175ec98b5cc47b8735b12449aa7912 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/HistoryEntry.java @@ -0,0 +1,106 @@ +/* + * Copyright 2014 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.person.Person; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.exceptions.NotFetchedException; +import ch.systemsx.cisd.base.annotation.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.Date; + +/** + * Class automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + */ +@JsonObject("dto.entity.history.HistoryEntry") +public abstract class HistoryEntry implements Serializable +{ + private static final long serialVersionUID = 1L; + + @JsonProperty + private HistoryEntryFetchOptions fetchOptions; + + @JsonProperty + private Date validFrom; + + @JsonProperty + private Date validTo; + + @JsonProperty + private Person author; + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public HistoryEntryFetchOptions getFetchOptions() + { + return fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setFetchOptions(HistoryEntryFetchOptions fetchOptions) + { + this.fetchOptions = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public Date getValidFrom() + { + return validFrom; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setValidFrom(Date validFrom) + { + this.validFrom = validFrom; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public Date getValidTo() + { + return validTo; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setValidTo(Date validTo) + { + this.validTo = validTo; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public Person getAuthor() + { + if (getFetchOptions().hasAuthor()) + { + return author; + } + else + { + throw new NotFetchedException("Author has not been fetched."); + } + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setAuthor(Person author) + { + this.author = author; + } + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/IRelationType.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/IRelationType.java new file mode 100644 index 0000000000000000000000000000000000000000..d1d7b6ca71ed9927c2efb7faefe92e2db9d43f89 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/IRelationType.java @@ -0,0 +1,25 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +/** + * @author pkupczyk + */ +public interface IRelationType +{ + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/PropertyHistoryEntry.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/PropertyHistoryEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..710bb153d1c0e0b435409f8a36ef568bd09672af --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/PropertyHistoryEntry.java @@ -0,0 +1,61 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * @author pkupczyk + */ +@JsonObject("dto.entity.history.PropertyHistoryEntry") +public class PropertyHistoryEntry extends HistoryEntry +{ + + private static final long serialVersionUID = 1L; + + @JsonProperty + private String propertyName; + + @JsonProperty + private String propertyValue; + + @JsonIgnore + public String getPropertyName() + { + return propertyName; + } + + public void setPropertyName(String propertyName) + { + this.propertyName = propertyName; + } + + @JsonIgnore + public String getPropertyValue() + { + return propertyValue; + } + + public void setPropertyValue(String propertyValue) + { + this.propertyValue = propertyValue; + } + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/RelationHistoryEntry.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/RelationHistoryEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..52accde134a503b424dffd83e884297fbc98de80 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/RelationHistoryEntry.java @@ -0,0 +1,62 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.IObjectId; +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * @author pkupczyk + */ +@JsonObject("dto.entity.history.RelationHistoryEntry") +public class RelationHistoryEntry extends HistoryEntry +{ + + private static final long serialVersionUID = 1L; + + @JsonProperty + private IRelationType relationType; + + @JsonProperty + private IObjectId relatedObjectId; + + @JsonIgnore + public IRelationType getRelationType() + { + return relationType; + } + + public void setRelationType(IRelationType relationType) + { + this.relationType = relationType; + } + + @JsonIgnore + public IObjectId getRelatedObjectId() + { + return relatedObjectId; + } + + public void setRelatedObjectId(IObjectId relatedObjectId) + { + this.relatedObjectId = relatedObjectId; + } + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/SampleRelationType.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/SampleRelationType.java new file mode 100644 index 0000000000000000000000000000000000000000..f9810b6cf50bd7c4d1d32491ba986ff9723a4023 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/history/SampleRelationType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history; + +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * @author pkupczyk + */ +@JsonObject("dto.entity.history.SampleRelationType") +public enum SampleRelationType implements IRelationType +{ + + SPACE, EXPERIMENT, PARENT, CHILD, CONTAINER, COMPONENT, DATA_SET + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/material/Material.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/material/Material.java index b8f8c104e9769215f2ab6353a2699f54eabbe168..93679d016add65fb51afc340493122cb21928300 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/material/Material.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/material/Material.java @@ -15,6 +15,7 @@ */ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.material; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModificationDateHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IPropertiesHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IRegistrationDateHolder; @@ -32,6 +33,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.Date; +import java.util.List; import java.util.Map; import java.util.Set; @@ -55,6 +57,9 @@ public class Material implements Serializable, IModificationDateHolder, IRegistr @JsonProperty private MaterialType type; + @JsonProperty + private List<HistoryEntry> history; + @JsonProperty private Date registrationDate; @@ -132,6 +137,26 @@ public class Material implements Serializable, IModificationDateHolder, IRegistr this.type = type; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public List<HistoryEntry> getHistory() + { + if (getFetchOptions().hasHistory()) + { + return history; + } + else + { + throw new NotFetchedException("History have not been fetched."); + } + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setHistory(List<HistoryEntry> history) + { + this.history = history; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} @JsonIgnore @Override diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/sample/Sample.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/sample/Sample.java index 68a701566fdda6781806a9d1d5c59c3aad1b25fe..14177541979074713197b0ebde5ef6e4d03acd0f 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/sample/Sample.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/sample/Sample.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.attachment.Attachment; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IAttachmentsHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModificationDateHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IModifierHolder; @@ -102,6 +103,9 @@ public class Sample implements Serializable, ISpaceHolder, IModifierHolder, IMod @JsonProperty private List<DataSet> dataSets; + @JsonProperty + private List<HistoryEntry> history; + @JsonProperty private Set<Tag> tags; @@ -399,6 +403,26 @@ public class Sample implements Serializable, ISpaceHolder, IModifierHolder, IMod this.dataSets = dataSets; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + @JsonIgnore + public List<HistoryEntry> getHistory() + { + if (getFetchOptions().hasHistory()) + { + return history; + } + else + { + throw new NotFetchedException("History have not been fetched."); + } + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public void setHistory(List<HistoryEntry> history) + { + this.history = history; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} @JsonIgnore @Override diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/dataset/DataSetFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/dataset/DataSetFetchOptions.java index 96cc1bdeaa93833d5a7b23f8dae34aecd88e0835..36e26059e21a12c930a87d842cc6af3e25ed3f16 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/dataset/DataSetFetchOptions.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/dataset/DataSetFetchOptions.java @@ -19,6 +19,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSe import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetTypeFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.ExternalDataFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.property.PropertyFetchOptions; @@ -57,6 +58,9 @@ public class DataSetFetchOptions implements Serializable @JsonProperty private DataSetTypeFetchOptions type; + @JsonProperty + private HistoryEntryFetchOptions history; + @JsonProperty private PersonFetchOptions modifier; @@ -229,6 +233,28 @@ public class DataSetFetchOptions implements Serializable return type != null; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistory() + { + if (history == null) + { + history = new HistoryEntryFetchOptions(); + } + return history; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistoryUsing(HistoryEntryFetchOptions fetchOptions) + { + return history = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public boolean hasHistory() + { + return history != null; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} public PersonFetchOptions withModifier() { diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/experiment/ExperimentFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/experiment/ExperimentFetchOptions.java index 33f4e16a21bbe2544788318edfb7bb7d82f6bc0e..25030d35108061d5b6c893224125e2e7e99662fb 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/experiment/ExperimentFetchOptions.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/experiment/ExperimentFetchOptions.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.attachment.AttachmentFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project.ProjectFetchOptions; @@ -48,6 +49,9 @@ public class ExperimentFetchOptions implements Serializable @JsonProperty private SampleFetchOptions samples; + @JsonProperty + private HistoryEntryFetchOptions history; + @JsonProperty private PropertyFetchOptions properties; @@ -154,6 +158,28 @@ public class ExperimentFetchOptions implements Serializable return samples != null; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistory() + { + if (history == null) + { + history = new HistoryEntryFetchOptions(); + } + return history; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistoryUsing(HistoryEntryFetchOptions fetchOptions) + { + return history = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public boolean hasHistory() + { + return history != null; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} public PropertyFetchOptions withProperties() { diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/history/HistoryEntryFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/history/HistoryEntryFetchOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..0092da64bb3cbe771772daf18fffe9a7678eab36 --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/history/HistoryEntryFetchOptions.java @@ -0,0 +1,56 @@ +/* + * Copyright 2014 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history; + +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; +import ch.systemsx.cisd.base.annotation.JsonObject; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; + +/** + * Class automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + */ +@JsonObject("dto.fetchoptions.history.HistoryEntryFetchOptions") +public class HistoryEntryFetchOptions implements Serializable +{ + private static final long serialVersionUID = 1L; + + @JsonProperty + private PersonFetchOptions author; + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public PersonFetchOptions withAuthor() + { + if (author == null) + { + author = new PersonFetchOptions(); + } + return author; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public PersonFetchOptions withAuthorUsing(PersonFetchOptions fetchOptions) + { + return author = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public boolean hasAuthor() + { + return author != null; + } + +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/material/MaterialFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/material/MaterialFetchOptions.java index cee251430fc05b4d16ba4ffb45f5bd604f391071..dc6e64caea5612b65f3d8e04241ce1f7bc3bc015 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/material/MaterialFetchOptions.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/material/MaterialFetchOptions.java @@ -15,6 +15,7 @@ */ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; @@ -35,6 +36,9 @@ public class MaterialFetchOptions implements Serializable @JsonProperty private MaterialTypeFetchOptions type; + @JsonProperty + private HistoryEntryFetchOptions history; + @JsonProperty private PersonFetchOptions registrator; @@ -69,6 +73,28 @@ public class MaterialFetchOptions implements Serializable return type != null; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistory() + { + if (history == null) + { + history = new HistoryEntryFetchOptions(); + } + return history; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistoryUsing(HistoryEntryFetchOptions fetchOptions) + { + return history = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public boolean hasHistory() + { + return history != null; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} public PersonFetchOptions withRegistrator() { diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/sample/SampleFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/sample/SampleFetchOptions.java index 722085e91abb6d643564eba714074c2b5e4b99a6..42bd728e740771acf1964e6789ffb50fc484bd57 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/sample/SampleFetchOptions.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/sample/SampleFetchOptions.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.sample; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.attachment.AttachmentFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.property.PropertyFetchOptions; @@ -67,6 +68,9 @@ public class SampleFetchOptions implements Serializable @JsonProperty private DataSetFetchOptions dataSets; + @JsonProperty + private HistoryEntryFetchOptions history; + @JsonProperty private TagFetchOptions tags; @@ -299,6 +303,28 @@ public class SampleFetchOptions implements Serializable return dataSets != null; } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistory() + { + if (history == null) + { + history = new HistoryEntryFetchOptions(); + } + return history; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public HistoryEntryFetchOptions withHistoryUsing(HistoryEntryFetchOptions fetchOptions) + { + return history = fetchOptions; + } + + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} + public boolean hasHistory() + { + return history != null; + } + // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator} public TagFetchOptions withTags() { diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java index aa5d31846e6b91acc347cc10a4f714a7e03033f4..918372453e2a510023fbc57d936b254227594bc0 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java @@ -1,6 +1,7 @@ package ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators; import java.io.FileNotFoundException; +import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -15,6 +16,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.FileFormatTy import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.LocatorType; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.history.HistoryEntry; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.interfaces.IParentChildrenHolder; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.material.MaterialType; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.person.Person; @@ -32,6 +34,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.FileFo import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.LocatorTypeFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.history.HistoryEntryFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.material.MaterialTypeFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions; @@ -80,6 +83,9 @@ public class Generator extends AbstractGenerator gen.addPluralFetchedField("List<Sample>", List.class.getName(), "contained", "Contained samples", SampleFetchOptions.class); gen.addPluralFetchedField("List<DataSet>", List.class.getName(), "dataSets", "Data sets", DataSetFetchOptions.class); gen.addClassForImport(DataSet.class); + gen.addPluralFetchedField("List<HistoryEntry>", List.class.getName(), "history", "History", HistoryEntryFetchOptions.class); + gen.addClassForImport(HistoryEntry.class); + addTags(gen); addRegistrator(gen); addModifier(gen); @@ -158,6 +164,9 @@ public class Generator extends AbstractGenerator gen.addPluralFetchedField("List<Sample>", List.class.getName(), "samples", "Samples", SampleFetchOptions.class); gen.addClassForImport(Sample.class); + gen.addPluralFetchedField("List<HistoryEntry>", List.class.getName(), "history", "History", HistoryEntryFetchOptions.class); + gen.addClassForImport(HistoryEntry.class); + addProperties(gen); addTags(gen); addRegistrator(gen); @@ -206,6 +215,10 @@ public class Generator extends AbstractGenerator addTags(gen); gen.addFetchedField(DataSetType.class, "type", "Data Set type", DataSetTypeFetchOptions.class); + + gen.addPluralFetchedField("List<HistoryEntry>", List.class.getName(), "history", "History", HistoryEntryFetchOptions.class); + gen.addClassForImport(HistoryEntry.class); + // add data set type // add data store addModificationDate(gen); @@ -384,6 +397,10 @@ public class Generator extends AbstractGenerator gen.addSimpleField(MaterialPermId.class, "permId"); addCode(gen); gen.addFetchedField(MaterialType.class, "type", "Material type", MaterialTypeFetchOptions.class); + + gen.addPluralFetchedField("List<HistoryEntry>", List.class.getName(), "history", "History", HistoryEntryFetchOptions.class); + gen.addClassForImport(HistoryEntry.class); + addRegistrationDate(gen); addRegistrator(gen); addModificationDate(gen); @@ -403,6 +420,15 @@ public class Generator extends AbstractGenerator return gen; } + private static DtoGenerator createHistoryEntryGenerator() + { + DtoGenerator gen = new DtoGenerator("history", "HistoryEntry", HistoryEntryFetchOptions.class); + gen.addSimpleField(Date.class, "validFrom"); + gen.addSimpleField(Date.class, "validTo"); + gen.addFetchedField(Person.class, "author", "Author", PersonFetchOptions.class); + return gen; + } + public static void main(String[] args) throws FileNotFoundException { List<DtoGenerator> list = new LinkedList<DtoGenerator>(); @@ -424,6 +450,7 @@ public class Generator extends AbstractGenerator list.add(createLocatorType()); list.add(createFileFormatType()); list.add(createExternalDataGenerator()); + list.add(createHistoryEntryGenerator()); for (DtoGenerator gen : list) {