diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DefaultEntityOperationService.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DefaultEntityOperationService.java index 89748b8649d19c255d3cd8bd0332ab96633effb1..3d90fe0d178f8e36b997f31e93fe80dd804889ee 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DefaultEntityOperationService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/DefaultEntityOperationService.java @@ -38,6 +38,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialUpdateDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.MetaprojectUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleUpdatesDTO; +import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyUpdatesDTO; public class DefaultEntityOperationService<T extends DataSetInformation> implements IEntityOperationService<T> @@ -90,6 +91,7 @@ public class DefaultEntityOperationService<T extends DataSetInformation> impleme List<DataSetBatchUpdatesDTO> dataSetUpdates = details.getDataSetUpdates(); List<NewMetaproject> metaprojectRegistrations = details.getMetaprojectRegistrations(); List<MetaprojectUpdatesDTO> metaprojectUpdates = details.getMetaprojectUpdates(); + List<VocabularyUpdatesDTO> vocabularyUpdates = details.getVocabularyUpdates(); List<NewExternalData> dataSetRegistrations = new ArrayList<NewExternalData>(); for (DataSetRegistrationInformation<?> dsRegistration : details.getDataSetRegistrations()) @@ -102,7 +104,7 @@ public class DefaultEntityOperationService<T extends DataSetInformation> impleme details.getRegistrationId(), details.tryUserIdOrNull(), spaceRegistrations, projectRegistrations, experimentRegistrations, experimentUpdates, sampleUpdates, sampleRegistrations, materialRegistrations, materialUpdates, dataSetRegistrations, - dataSetUpdates, metaprojectRegistrations, metaprojectUpdates); + dataSetUpdates, metaprojectRegistrations, metaprojectUpdates, vocabularyUpdates); } } \ No newline at end of file diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java index 151beb4be795b29020672ccb595e8b8f9b9e217c..5f82970bd0c30deda2246d2ecade84db566c9da8 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -46,6 +47,7 @@ import ch.systemsx.cisd.etlserver.registrator.api.v1.IMetaproject; import ch.systemsx.cisd.etlserver.registrator.api.v1.IProject; import ch.systemsx.cisd.etlserver.registrator.api.v1.ISample; import ch.systemsx.cisd.etlserver.registrator.api.v1.ISpace; +import ch.systemsx.cisd.etlserver.registrator.api.v1.IVocabularyTerm; import ch.systemsx.cisd.etlserver.registrator.api.v1.SecondaryTransactionFailure; import ch.systemsx.cisd.etlserver.registrator.api.v1.impl.RollbackStack.IRollbackStackDelegate; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; @@ -69,7 +71,9 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetBatchUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialUpdateDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.MetaprojectUpdatesDTO; +import ch.systemsx.cisd.openbis.generic.shared.dto.NewVocabularyTerm; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleUpdatesDTO; +import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifierFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; @@ -744,7 +748,9 @@ public abstract class AbstractTransactionState<T extends DataSetInformation> openBisService.tryGetVocabulary(code); if (vocabulary != null) { - return new Vocabulary(vocabulary); + Vocabulary apiVocabulary = new Vocabulary(vocabulary); + vocabulariesToBeUpdated.add(apiVocabulary); + return apiVocabulary; } return null; } @@ -1003,13 +1009,15 @@ public abstract class AbstractTransactionState<T extends DataSetInformation> List<DataSetBatchUpdatesDTO> dataSetUpdates = convertDataSetsToBeUpdated(); List<NewMetaproject> metaprojectRegistrations = convertMetaprojectsToBeRegistered(); List<MetaprojectUpdatesDTO> metaprojectUpdates = convertMetaprojectsToBeUpdated(); + List<VocabularyUpdatesDTO> vocabularyUpdates = covertVocabulariesToBeUpdated(); AtomicEntityOperationDetails<T> registrationDetails = new AtomicEntityOperationDetails<T>(registrationId, getUserId(), spaceRegistrations, projectRegistrations, experimentUpdates, experimentRegistrations, sampleUpdates, sampleRegistrations, materialRegistrations, materialUpdates, dataSetRegistrations, - dataSetUpdates, metaprojectRegistrations, metaprojectUpdates); + dataSetUpdates, metaprojectRegistrations, metaprojectUpdates, + vocabularyUpdates); return registrationDetails; } @@ -1132,6 +1140,32 @@ public abstract class AbstractTransactionState<T extends DataSetInformation> return result; } + private List<VocabularyUpdatesDTO> covertVocabulariesToBeUpdated() + { + List<VocabularyUpdatesDTO> result = new ArrayList<VocabularyUpdatesDTO>(); + for (Vocabulary v : vocabulariesToBeUpdated) + { + List<NewVocabularyTerm> newTerms = new LinkedList<NewVocabularyTerm>(); + + for (IVocabularyTerm t : v.getNewTerms()) + { + NewVocabularyTerm newTerm = + new NewVocabularyTerm(t.getCode(), t.getDescription(), t.getLabel(), + t.getOrdinal()); + newTerms.add(newTerm); + } + + VocabularyUpdatesDTO updates = + new VocabularyUpdatesDTO(v.getVocabulary().getId(), v.getCode(), + v.getDescription(), v.isManagedInternally(), + v.isInternalNamespace(), v.isChosenFromList(), v.getUrlTemplate(), + newTerms); + + result.add(updates); + } + return result; + } + @Override public boolean isCommitted() { diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/Vocabulary.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/Vocabulary.java index aedcf3b39a9cf4b762e77a31c80d41698fe37423..895d228d99a7bb66d658a817ce3bd038d560e22b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/Vocabulary.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/Vocabulary.java @@ -54,14 +54,12 @@ public class Vocabulary extends VocabularyImmutable implements IVocabulary public void setInternalNamespace(boolean isInternalNamespace) { getVocabulary().setInternalNamespace(isInternalNamespace); - } @Override public void setChosenFromList(boolean isChosenFromList) { getVocabulary().setChosenFromList(isChosenFromList); - } @Override @@ -76,4 +74,9 @@ public class Vocabulary extends VocabularyImmutable implements IVocabulary newTerms.add(term); } + List<IVocabularyTerm> getNewTerms() + { + return newTerms; + } + } diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/VocabularyTerm.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/VocabularyTerm.java index 39d31765f35a89b3b3d0d2df48552eff2be6f4ee..1dd24e65e17656e610709a0ff3a97c0db6a3fec4 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/VocabularyTerm.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/VocabularyTerm.java @@ -33,7 +33,7 @@ public class VocabularyTerm extends VocabularyTermImmutable implements IVocabula @Override public void setCode(String code) { - getVocabularyTerm().setCode(getCode()); + getVocabularyTerm().setCode(code); } @Override diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/AtomicEntityOperationDetails.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/AtomicEntityOperationDetails.java index 039c7e431b8868115f08b420bff7d3cffc43db06..dd40e96053a92c06b7e2462c4b48225169e43cce 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/AtomicEntityOperationDetails.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/AtomicEntityOperationDetails.java @@ -34,6 +34,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialUpdateDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.MetaprojectUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleUpdatesDTO; +import ch.systemsx.cisd.openbis.generic.shared.dto.VocabularyUpdatesDTO; /** * An object that captures the state for performing the registration of one or many openBIS entities @@ -75,6 +76,8 @@ public class AtomicEntityOperationDetails<T extends DataSetInformation> implemen private final List<MetaprojectUpdatesDTO> metaprojectUpdates; + private final List<VocabularyUpdatesDTO> vocabularyUpdates; + public AtomicEntityOperationDetails(TechId registrationId, String userIdOrNull, List<NewSpace> spaceRegistrations, List<NewProject> projectRegistrations, List<ExperimentUpdatesDTO> experimentUpdates, @@ -85,7 +88,8 @@ public class AtomicEntityOperationDetails<T extends DataSetInformation> implemen List<DataSetRegistrationInformation<T>> dataSetRegistrations, List<DataSetBatchUpdatesDTO> dataSetUpdates, List<NewMetaproject> metaprojectRegistrations, - List<MetaprojectUpdatesDTO> metaprojectUpdates) + List<MetaprojectUpdatesDTO> metaprojectUpdates, + List<VocabularyUpdatesDTO> vocabularyUpdates) { this.registrationId = registrationId; this.userIdOrNull = userIdOrNull; @@ -102,6 +106,7 @@ public class AtomicEntityOperationDetails<T extends DataSetInformation> implemen this.materialUpdates = new ArrayList<MaterialUpdateDTO>(materialUpdates); this.metaprojectRegistrations = new ArrayList<NewMetaproject>(metaprojectRegistrations); this.metaprojectUpdates = new ArrayList<MetaprojectUpdatesDTO>(metaprojectUpdates); + this.vocabularyUpdates = new ArrayList<VocabularyUpdatesDTO>(vocabularyUpdates); } public TechId getRegistrationId() @@ -174,4 +179,9 @@ public class AtomicEntityOperationDetails<T extends DataSetInformation> implemen return metaprojectUpdates; } + public List<VocabularyUpdatesDTO> getVocabularyUpdates() + { + return vocabularyUpdates; + } + }