commit 65d2936da23181f34fe6561dd4ae55c21c81d21b
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue Jun 26 15:59:19 2018 +0200

    fix #7313 adding kindOfUnit terms to new vocabulary

diff --git a/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java b/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
index b7793556..5cbb0818 100644
--- a/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
+++ b/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
@@ -39,9 +39,12 @@ import eu.etaxonomy.cdm.api.application.CdmRepository;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Institution;
+import eu.etaxonomy.cdm.model.common.DefinedTerm;
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.ExtensionType;
 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
 import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 import eu.etaxonomy.cdm.model.name.Registration;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
@@ -160,20 +163,35 @@ public class RegistrationRequiredDataInserter extends AbstractDataInserter {
         assureGroupHas(groupSubmitter, new CdmAuthority(CdmPermissionClass.COLLECTION, CREATE_READ).toString());
         repo.getGroupService().saveOrUpdate(groupSubmitter);
 
-        if(repo.getTermService().find(KindOfUnitTerms.SPECIMEN().getUuid()) == null){
-            repo.getTermService().save(KindOfUnitTerms.SPECIMEN());
+
+        DefinedTermBase kouSpecimen = repo.getTermService().find(KindOfUnitTerms.SPECIMEN().getUuid());
+        DefinedTermBase kouImage = repo.getTermService().find(KindOfUnitTerms.PUBLISHED_IMAGE().getUuid());
+        DefinedTermBase kouUnpublishedImage = repo.getTermService().find(KindOfUnitTerms.UNPUBLISHED_IMAGE().getUuid());
+        DefinedTermBase kouCulture = repo.getTermService().find(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE().getUuid());
+
+        if(kouSpecimen == null){
+            kouSpecimen = repo.getTermService().save(KindOfUnitTerms.SPECIMEN());
         }
-        if(repo.getTermService().find(KindOfUnitTerms.PUBLISHED_IMAGE().getUuid()) == null){
-            repo.getTermService().save(KindOfUnitTerms.PUBLISHED_IMAGE());
+        if(kouImage == null){
+            kouImage = repo.getTermService().save(KindOfUnitTerms.PUBLISHED_IMAGE());
         }
-        if(repo.getTermService().find(KindOfUnitTerms.UNPUBLISHED_IMAGE().getUuid()) == null){
-            repo.getTermService().save(KindOfUnitTerms.UNPUBLISHED_IMAGE());
+        if(kouUnpublishedImage == null){
+            kouUnpublishedImage = repo.getTermService().save(KindOfUnitTerms.UNPUBLISHED_IMAGE());
         }
-        if(repo.getTermService().find(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE().getUuid()) == null){
-            repo.getTermService().save(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE());
+        if(kouCulture == null){
+            kouCulture = repo.getTermService().save(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE());
         }
 
+        TermVocabulary<DefinedTerm> kindOfUnitVocabulary = repo.getVocabularyService().find(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY().getUuid());
+        if(repo.getVocabularyService().find(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY().getUuid()) == null){
+            kindOfUnitVocabulary = repo.getVocabularyService().save(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY());
+            kindOfUnitVocabulary.addTerm((DefinedTerm)kouSpecimen);
+            kindOfUnitVocabulary.addTerm((DefinedTerm)kouImage);
+            kindOfUnitVocabulary.addTerm((DefinedTerm)kouUnpublishedImage);
+            kindOfUnitVocabulary.addTerm((DefinedTerm)kouCulture);
+        }
         txStatus.flush();
+
         repo.commitTransaction(txStatus);
 
     }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/KindOfUnitTerms.java b/src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/KindOfUnitTerms.java
index e51f2bde..07798776 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/KindOfUnitTerms.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/KindOfUnitTerms.java
@@ -12,6 +12,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
 
 /**
  * Terms to be used as kindOfUnit for {@link SpecimenOrObservationBase#setKindOfUnit()}.
@@ -30,11 +31,15 @@ public class KindOfUnitTerms {
     private static final UUID UUID_UNPUBLISHED_IMAGE = UUID.fromString("87adcd8d-ce69-4d16-ac35-4e77fb698e00");
     private static final UUID UUID_CULTURE_METABOLIC_INACTIVE = UUID.fromString("fc1ac3b2-fde4-43c0-a100-48053b88c550");
 
+    private static final UUID UUID_KIND_OF_UNIT_VOCAB = UUID.fromString("88b7e7ab-ab99-4760-9b66-c070b98148fc");
+
     private static DefinedTerm specimen = null;
     private static DefinedTerm publishedImage = null;
     private static DefinedTerm unpublishedImage = null;
     private static DefinedTerm cultureMetabolicInactive = null;
 
+    private static TermVocabulary<DefinedTerm> kindOfUnitVocabulary = null;
+
     public static DefinedTerm SPECIMEN() {
         if(specimen == null){
             specimen = DefinedTerm.NewInstance(TermType.KindOfUnit, "Specimen", "Specimen", "");
@@ -67,4 +72,13 @@ public class KindOfUnitTerms {
         return cultureMetabolicInactive;
     }
 
+    public static TermVocabulary<DefinedTerm> KIND_OF_UNIT_VOCABULARY() {
+        if(kindOfUnitVocabulary == null){
+            kindOfUnitVocabulary = TermVocabulary.NewInstance(TermType.KindOfUnit);
+            kindOfUnitVocabulary.setTitleCache("Registration Kind-of-Units", true);
+            kindOfUnitVocabulary.setUuid(UUID_KIND_OF_UNIT_VOCAB);
+        }
+        return kindOfUnitVocabulary;
+    }
+
 }
