Skip to content
Snippets Groups Projects
initialize-master-data.py 2.39 KiB
Newer Older
  • Learn to ignore specific revisions
  • import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.DataType as DataType
    
    tr = service.transaction()
    
    
    vocabulary_GENDER = tr.getOrCreateNewVocabulary('GENDER')
    vocabulary_GENDER.setDescription('Gender of a biological sample.')
    vocabulary_GENDER.setUrlTemplate(None)
    vocabulary_GENDER.setManagedInternally(False)
    vocabulary_GENDER.setInternalNamespace(False)
    vocabulary_GENDER.setChosenFromList(True)
    
    vocabulary_term_GENDER_MALE = tr.createNewVocabularyTerm('MALE')
    vocabulary_term_GENDER_MALE.setDescription(None)
    vocabulary_term_GENDER_MALE.setLabel('MALE')
    vocabulary_term_GENDER_MALE.setOrdinal(1)
    vocabulary_GENDER.addTerm(vocabulary_term_GENDER_MALE)
    
    vocabulary_term_GENDER_FEMALE = tr.createNewVocabularyTerm('FEMALE')
    vocabulary_term_GENDER_FEMALE.setDescription(None)
    vocabulary_term_GENDER_FEMALE.setLabel('FEMALE')
    vocabulary_term_GENDER_FEMALE.setOrdinal(1)
    vocabulary_GENDER.addTerm(vocabulary_term_GENDER_FEMALE)
    
    
    vocabulary_INTERNAL = tr.getOrCreateNewVocabulary('INTERNAL')
    
    vocabulary_INTERNAL.setDescription('Internal vocabulary')
    vocabulary_INTERNAL.setUrlTemplate(None)
    vocabulary_INTERNAL.setManagedInternally(False)
    vocabulary_INTERNAL.setInternalNamespace(True)
    vocabulary_INTERNAL.setChosenFromList(True)
    
    vocabulary_INTERNAL_UNKNOWN = tr.createNewVocabularyTerm('UNKNOWN')
    vocabulary_INTERNAL_UNKNOWN.setDescription(None)
    vocabulary_INTERNAL_UNKNOWN.setLabel('UNKNOWN')
    vocabulary_INTERNAL_UNKNOWN.setOrdinal(1)
    vocabulary_INTERNAL.addTerm(vocabulary_INTERNAL_UNKNOWN)
    
    prop_type_TEST = tr.getOrCreateNewPropertyType('GENDER', DataType.CONTROLLEDVOCABULARY)
    prop_type_TEST.setLabel('Gender')
    prop_type_TEST.setManagedInternally(False)
    prop_type_TEST.setInternalNamespace(False)
    prop_type_TEST.setVocabulary(vocabulary_GENDER)
    
    samp_type_MD_TEST = tr.getOrCreateNewSampleType('MD_TEST')
    samp_type_MD_TEST.setDescription('MD_TEST')
    samp_type_MD_TEST.setListable(True)
    samp_type_MD_TEST.setShowContainer(False)
    samp_type_MD_TEST.setShowParents(False)
    samp_type_MD_TEST.setSubcodeUnique(False)
    samp_type_MD_TEST.setAutoGeneratedCode(False)
    samp_type_MD_TEST.setShowParentMetadata(False)
    samp_type_MD_TEST.setGeneratedCodePrefix('MD')
    
    assignment_samp_type_MD_TEST = tr.assignPropertyType(samp_type_MD_TEST, prop_type_TEST)
    assignment_samp_type_MD_TEST.setMandatory(False)
    assignment_samp_type_MD_TEST.setSection(None)
    assignment_samp_type_MD_TEST.setPositionInForms(1)
    assignment_samp_type_MD_TEST.setShownEdit(True)