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 List<SampleType> filter( final List<SampleType> sampleTypes, final boolean onlyListable) { final List<SampleType> result = new ArrayList<SampleType>(); for (final SampleType sampleType : sampleTypes) { if (onlyListable && sampleType.isListable() == false) { continue; } result.add(sampleType); } return result; }
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); }
private static SampleTypeModel createTypeInFileModel() { final SampleType typeInFile = new SampleType(); typeInFile.setCode(SampleType.DEFINED_IN_FILE); typeInFile.setListable(false); return new SampleTypeModel(typeInFile); }
public SampleTypeModel(final SampleType sampleType) { set(ModelDataPropertyNames.CODE, sampleType.getCode()); set(ModelDataPropertyNames.OBJECT, sampleType); }