private static void setDatabaseInstance(SampleType sampleType, DatabaseInstance instance) {
   if (sampleType.getDatabaseInstance() != null) {
     assert sampleType.getDatabaseInstance().equals(instance)
         : "sample types from more than one database instance are not supported";
   } else {
     sampleType.setDatabaseInstance(instance);
   }
 }
  private static SampleTypeModel createAllTypesModel(List<SampleType> basicTypes) {
    final SampleType allSampleType = new SampleType();
    allSampleType.setCode(EntityType.ALL_TYPES_CODE);
    allSampleType.setListable(true);

    Set<SampleTypePropertyType> allPropertyTypes = new HashSet<SampleTypePropertyType>();
    for (SampleType basicType : basicTypes) {
      allPropertyTypes.addAll(basicType.getAssignedPropertyTypes());
      setDatabaseInstance(allSampleType, basicType.getDatabaseInstance());
    }

    allSampleType.setSampleTypePropertyTypes(
        new ArrayList<SampleTypePropertyType>(allPropertyTypes));

    return new SampleTypeModel(allSampleType);
  }