use of uk.ac.bbsrc.tgac.miso.core.data.type.ConsentLevel in project miso-lims by miso-lims.
the class ConstantsController method rebuildConstants.
private void rebuildConstants() {
try {
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.createObjectNode();
node.put("docsVersion", getDocsVersion());
node.put("isDetailedSample", detailedSample);
node.put("automaticBarcodes", autoGenerateIdBarcodes);
node.put("boxScannerEnabled", boxScannerEnabled);
node.put("newOptionSopUrl", newOptionSopUrl);
final Collection<SampleValidRelationship> relationships = sampleValidRelationshipService.getAll();
addJsonArray(mapper, node, "libraryDesigns", libraryDesignService.list(), Dtos::asDto);
addJsonArray(mapper, node, "libraryTypes", libraryTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "librarySelections", librarySelectionService.list(), Dtos::asDto);
addJsonArray(mapper, node, "libraryStrategies", libraryStrategyService.list(), Dtos::asDto);
addJsonArray(mapper, node, "libraryDesignCodes", libraryDesignCodeService.list(), Dtos::asDto);
Set<Long> activePlatforms = sequencerService.list().stream().filter(Instrument::isActive).map(sequencer -> sequencer.getInstrumentModel().getId()).collect(Collectors.toSet());
addJsonArray(mapper, node, "instrumentModels", instrumentModelService.list(), platform -> {
InstrumentModelDto dto = Dtos.asDto(platform);
dto.setActive(activePlatforms.contains(platform.getId()));
return dto;
});
addJsonArray(mapper, node, "kitDescriptors", kitService.list(), Dtos::asDto);
addJsonArray(mapper, node, "sampleClasses", sampleClassService.list(), Dtos::asDto);
addJsonArray(mapper, node, "sampleValidRelationships", relationships, Dtos::asDto);
addJsonArray(mapper, node, "detailedQcStatuses", detailedQcStatusService.list(), Dtos::asDto);
addJsonArray(mapper, node, "subprojects", subprojectService.list(), Dtos::asDto);
addJsonArray(mapper, node, "labs", labService.list(), Dtos::asDto);
addJsonArray(mapper, node, "tissueOrigins", tissueOriginService.list(), Dtos::asDto);
addJsonArray(mapper, node, "tissueTypes", tissueTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "tissueMaterials", tissueMaterialService.list(), Dtos::asDto);
addJsonArray(mapper, node, "tissuePieceTypes", tissuePieceTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "stains", stainService.list(), Dtos::asDto);
addJsonArray(mapper, node, "targetedSequencings", targetedSequencingService.list(), Dtos::asDto);
addJsonArray(mapper, node, "samplePurposes", samplePurposeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "sequencingParameters", sequencingParametersService.list(), Dtos::asDto);
addJsonArray(mapper, node, "printerBackends", Arrays.asList(Backend.values()), Dtos::asDto);
addJsonArray(mapper, node, "printerDrivers", Arrays.asList(Driver.values()), Dtos::asDto);
addJsonArray(mapper, node, "boxSizes", boxSizeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "boxUses", boxUseService.list(), Dtos::asDto);
addJsonArray(mapper, node, "studyTypes", studyTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "sampleCategories", SampleClass.CATEGORIES, Function.identity());
createMap(mapper, node, "sampleSubcategories", SampleClass.SUBCATEGORIES);
addJsonArray(mapper, node, "submissionAction", Arrays.asList(SubmissionActionType.values()), SubmissionActionType::name);
addJsonArray(mapper, node, "containerModels", containerModelService.list(), Dtos::asDto);
addJsonArray(mapper, node, "poreVersions", containerService.listPoreVersions(), Dtos::asDto);
addJsonArray(mapper, node, "spikeIns", librarySpikeInService.list(), Dtos::asDto);
addJsonArray(mapper, node, "attachmentCategories", attachmentCategoryService.list(), Dtos::asDto);
addJsonArray(mapper, node, "runPurposes", runPurposeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "sequencingControlTypes", sequencingControlTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "scientificNames", scientificNameService.list(), Dtos::asDto);
addJsonArray(mapper, node, "pipelines", pipelineService.list(), Dtos::asDto);
addJsonArray(mapper, node, "runLibraryQcStatuses", runLibraryQcStatusService.list(), Dtos::asDto);
addJsonArray(mapper, node, "worksetCategories", worksetCategoryService.list(), Dtos::asDto);
addJsonArray(mapper, node, "worksetStages", worksetStageService.list(), Dtos::asDto);
addJsonArray(mapper, node, "metrics", metricService.list(), MetricDto::from);
addJsonArray(mapper, node, "metricSubcategories", metricSubcategoryService.list(), MetricSubcategoryDto::from);
addJsonArray(mapper, node, "assays", assayService.list(), AssayDto::from);
addJsonArray(mapper, node, "assayTests", assayTestService.list(), AssayTestDto::from);
addJsonArray(mapper, node, "sampleSheetFormats", Arrays.asList(SampleSheet.values()), SampleSheet::name);
Collection<IndexFamily> indexFamilies = indexFamilyService.list();
addJsonArray(mapper, node, "indexFamilies", indexFamilies, Dtos::asDto);
addJsonArray(mapper, node, "qcTypes", qcService.listQcTypes(), Dtos::asDto);
addJsonArray(mapper, node, "qcTargets", Arrays.asList(QcTarget.values()), Dtos::asDto);
addJsonArray(mapper, node, "concentrationUnits", Arrays.asList(ConcentrationUnit.values()), Dtos::asDto);
addJsonArray(mapper, node, "volumeUnits", Arrays.asList(VolumeUnit.values()), Dtos::asDto);
addJsonArray(mapper, node, "partitionQcTypes", partitionQcTypeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "referenceGenomes", referenceGenomeService.list(), Dtos::asDto);
addJsonArray(mapper, node, "spreadsheetFormats", Arrays.asList(SpreadSheetFormat.values()), Dtos::asDto);
addJsonArray(mapper, node, "sampleSpreadsheets", Arrays.asList(SampleSpreadSheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "librarySpreadsheets", Arrays.asList(LibrarySpreadSheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "libraryAliquotSpreadsheets", Arrays.asList(LibraryAliquotSpreadSheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "poolSpreadsheets", Arrays.asList(PoolSpreadSheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "partitionSpreadsheets", Arrays.asList(PartitionSpreadsheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "runLibrarySpreadsheets", Arrays.asList(RunLibrarySpreadsheets.values()), Dtos::asDto);
addJsonArray(mapper, node, "workflows", Arrays.asList(WorkflowName.values()), Dtos::asDto);
addJsonArray(mapper, node, "printableFields", Arrays.asList(PrintableField.values()), PrintableField::name);
ArrayNode platformTypes = node.putArray("platformTypes");
Collection<PlatformType> activePlatformTypes = instrumentModelService.listActivePlatformTypes();
for (PlatformType platformType : PlatformType.values()) {
ObjectNode dto = platformTypes.addObject();
dto.put("name", platformType.name());
dto.put("key", platformType.getKey());
dto.put("containerName", platformType.getContainerName());
dto.put("active", activePlatformTypes.contains(platformType));
dto.put("partitionName", platformType.getPartitionName());
dto.put("pluralPartitionName", platformType.getPluralPartitionName());
}
ArrayNode sampleTypes = node.putArray("sampleTypes");
for (SampleType sampleType : sampleTypeService.list()) {
if (!sampleType.isArchived()) {
sampleTypes.add(sampleType.getName());
}
}
ArrayNode donorSexes = node.putArray("donorSexes");
for (String label : DonorSex.getLabels()) {
donorSexes.add(label);
}
ArrayNode consentLevels = node.putArray("consentLevels");
for (ConsentLevel level : ConsentLevel.values()) {
consentLevels.add(level.getLabel());
}
ArrayNode strStatuses = node.putArray("strStatuses");
for (String label : StrStatus.getLabels()) {
strStatuses.add(label);
}
ArrayNode dilutionFactors = node.putArray("dilutionFactors");
for (String label : DilutionFactor.getLabels()) {
dilutionFactors.add(label);
}
ArrayNode illuminaChemistry = node.putArray("illuminaChemistry");
for (IlluminaChemistry chemistry : IlluminaChemistry.values()) {
illuminaChemistry.add(chemistry.name());
}
addIlluminaExperimentTypes(node);
addHealthTypes(node);
addIlluminaWorkflowTypes(node);
addInstrumentTypes(node);
addDataManglingPolicies(node);
addMetricCategories(node);
addThresholdTypes(node);
ObjectNode warningsNode = mapper.createObjectNode();
warningsNode.put("consentRevoked", "CONSENT REVOKED");
warningsNode.put("duplicateIndices", indexChecker.getErrorMismatchesMessage());
warningsNode.put("nearDuplicateIndices", indexChecker.getWarningMismatchesMessage());
warningsNode.put("lowQualityLibraries", "Low Quality Libraries");
warningsNode.put("missingIndex", "MISSING INDEX");
warningsNode.put("negativeVolume", "Negative Volume");
node.set("warningMessages", warningsNode);
node.put("errorEditDistance", indexChecker.getErrorMismatches());
node.put("warningEditDistance", indexChecker.getWarningMismatches());
node.put("genomeFolder", genomeFolder);
// Save the regenerated file in cache.
constantsJs = "Constants = " + mapper.writeValueAsString(node) + ";";
constantsTimestamp.set(System.currentTimeMillis() / 1000.0);
} catch (IOException e) {
throw new RestException(e);
}
}
Aggregations