Project

General

Profile

Revision 65d2936d

ID65d2936da23181f34fe6561dd4ae55c21c81d21b
Parent 64a28761
Child 1b767585

Added by Andreas Kohlbecker about 2 years ago

fix #7313 adding kindOfUnit terms to new vocabulary

View differences:

src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
39 39
import eu.etaxonomy.cdm.api.service.pager.Pager;
40 40
import eu.etaxonomy.cdm.model.agent.AgentBase;
41 41
import eu.etaxonomy.cdm.model.agent.Institution;
42
import eu.etaxonomy.cdm.model.common.DefinedTerm;
43
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
42 44
import eu.etaxonomy.cdm.model.common.ExtensionType;
43 45
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
44 46
import eu.etaxonomy.cdm.model.common.Group;
47
import eu.etaxonomy.cdm.model.common.TermVocabulary;
45 48
import eu.etaxonomy.cdm.model.common.TimePeriod;
46 49
import eu.etaxonomy.cdm.model.name.Registration;
47 50
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
......
160 163
        assureGroupHas(groupSubmitter, new CdmAuthority(CdmPermissionClass.COLLECTION, CREATE_READ).toString());
161 164
        repo.getGroupService().saveOrUpdate(groupSubmitter);
162 165

  
163
        if(repo.getTermService().find(KindOfUnitTerms.SPECIMEN().getUuid()) == null){
164
            repo.getTermService().save(KindOfUnitTerms.SPECIMEN());
166

  
167
        DefinedTermBase kouSpecimen = repo.getTermService().find(KindOfUnitTerms.SPECIMEN().getUuid());
168
        DefinedTermBase kouImage = repo.getTermService().find(KindOfUnitTerms.PUBLISHED_IMAGE().getUuid());
169
        DefinedTermBase kouUnpublishedImage = repo.getTermService().find(KindOfUnitTerms.UNPUBLISHED_IMAGE().getUuid());
170
        DefinedTermBase kouCulture = repo.getTermService().find(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE().getUuid());
171

  
172
        if(kouSpecimen == null){
173
            kouSpecimen = repo.getTermService().save(KindOfUnitTerms.SPECIMEN());
165 174
        }
166
        if(repo.getTermService().find(KindOfUnitTerms.PUBLISHED_IMAGE().getUuid()) == null){
167
            repo.getTermService().save(KindOfUnitTerms.PUBLISHED_IMAGE());
175
        if(kouImage == null){
176
            kouImage = repo.getTermService().save(KindOfUnitTerms.PUBLISHED_IMAGE());
168 177
        }
169
        if(repo.getTermService().find(KindOfUnitTerms.UNPUBLISHED_IMAGE().getUuid()) == null){
170
            repo.getTermService().save(KindOfUnitTerms.UNPUBLISHED_IMAGE());
178
        if(kouUnpublishedImage == null){
179
            kouUnpublishedImage = repo.getTermService().save(KindOfUnitTerms.UNPUBLISHED_IMAGE());
171 180
        }
172
        if(repo.getTermService().find(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE().getUuid()) == null){
173
            repo.getTermService().save(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE());
181
        if(kouCulture == null){
182
            kouCulture = repo.getTermService().save(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE());
174 183
        }
175 184

  
185
        TermVocabulary<DefinedTerm> kindOfUnitVocabulary = repo.getVocabularyService().find(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY().getUuid());
186
        if(repo.getVocabularyService().find(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY().getUuid()) == null){
187
            kindOfUnitVocabulary = repo.getVocabularyService().save(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY());
188
            kindOfUnitVocabulary.addTerm((DefinedTerm)kouSpecimen);
189
            kindOfUnitVocabulary.addTerm((DefinedTerm)kouImage);
190
            kindOfUnitVocabulary.addTerm((DefinedTerm)kouUnpublishedImage);
191
            kindOfUnitVocabulary.addTerm((DefinedTerm)kouCulture);
192
        }
176 193
        txStatus.flush();
194

  
177 195
        repo.commitTransaction(txStatus);
178 196

  
179 197
    }
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/KindOfUnitTerms.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.common.DefinedTerm;
14 14
import eu.etaxonomy.cdm.model.common.TermType;
15
import eu.etaxonomy.cdm.model.common.TermVocabulary;
15 16

  
16 17
/**
17 18
 * Terms to be used as kindOfUnit for {@link SpecimenOrObservationBase#setKindOfUnit()}.
......
30 31
    private static final UUID UUID_UNPUBLISHED_IMAGE = UUID.fromString("87adcd8d-ce69-4d16-ac35-4e77fb698e00");
31 32
    private static final UUID UUID_CULTURE_METABOLIC_INACTIVE = UUID.fromString("fc1ac3b2-fde4-43c0-a100-48053b88c550");
32 33

  
34
    private static final UUID UUID_KIND_OF_UNIT_VOCAB = UUID.fromString("88b7e7ab-ab99-4760-9b66-c070b98148fc");
35

  
33 36
    private static DefinedTerm specimen = null;
34 37
    private static DefinedTerm publishedImage = null;
35 38
    private static DefinedTerm unpublishedImage = null;
36 39
    private static DefinedTerm cultureMetabolicInactive = null;
37 40

  
41
    private static TermVocabulary<DefinedTerm> kindOfUnitVocabulary = null;
42

  
38 43
    public static DefinedTerm SPECIMEN() {
39 44
        if(specimen == null){
40 45
            specimen = DefinedTerm.NewInstance(TermType.KindOfUnit, "Specimen", "Specimen", "");
......
67 72
        return cultureMetabolicInactive;
68 73
    }
69 74

  
75
    public static TermVocabulary<DefinedTerm> KIND_OF_UNIT_VOCABULARY() {
76
        if(kindOfUnitVocabulary == null){
77
            kindOfUnitVocabulary = TermVocabulary.NewInstance(TermType.KindOfUnit);
78
            kindOfUnitVocabulary.setTitleCache("Registration Kind-of-Units", true);
79
            kindOfUnitVocabulary.setUuid(UUID_KIND_OF_UNIT_VOCAB);
80
        }
81
        return kindOfUnitVocabulary;
82
    }
83

  
70 84
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)