private void mergeProfiles(int p100Length, int gcpLength) { log.info("Merging profiles"); ArrayList<AssayType> dummyAssay = new ArrayList<>(); dummyAssay.add(AssayType.GCP); dummyAssay.add(AssayType.P100); List<Profile> profiles = profileRepository.findByAssayTypeInOrderByConcatDesc(dummyAssay); String prevConcat = null; String curConcat; List<Profile> bunchOfProfiles = null; for (Profile profile : profiles) { curConcat = profile.getReplicateAnnotation().getCellId() + profile.getReplicateAnnotation().getPertiname(); if (prevConcat == null) { prevConcat = curConcat; bunchOfProfiles = new ArrayList<>(); } if (!curConcat.equals(prevConcat)) { prevConcat = curConcat; MergedProfile mergedProfile = UtilsTransform.mergeProfiles(bunchOfProfiles, p100Length, gcpLength); mergedProfileRepository.save(mergedProfile); bunchOfProfiles = new ArrayList<>(); } else { bunchOfProfiles.add(profile); } } }