use of java.util.StringJoiner in project goci by EBISPOT.
the class StudySampleDescriptionService method generateUpdateDescription.
/**
* Generate a description of update made
*
* @param initialSampleDescription New initial sample description
* @param replicationSampleDescription New replicate sample description
* @param study Updated study
*/
private String generateUpdateDescription(String initialSampleDescription, String replicationSampleDescription, Study study) {
String updateDescription = null;
List<String> updateDetails = new ArrayList<>();
String initialSampleDescriptionUpdateDescription = checkForSampleDescriptionUpdate("Initial Sample Description", study.getInitialSampleSize(), initialSampleDescription);
if (initialSampleDescriptionUpdateDescription != null) {
updateDetails.add(initialSampleDescriptionUpdateDescription);
}
String replicationSampleDescriptionUpdateDescription = checkForSampleDescriptionUpdate("Replication Sample Description", study.getReplicateSampleSize(), replicationSampleDescription);
if (replicationSampleDescriptionUpdateDescription != null) {
updateDetails.add(replicationSampleDescriptionUpdateDescription);
}
StringJoiner updateDetailsJoiner = new StringJoiner(",");
if (!updateDetails.isEmpty()) {
updateDetails.forEach(s -> updateDetailsJoiner.add(s));
updateDescription = updateDetailsJoiner.toString();
}
return updateDescription;
}
use of java.util.StringJoiner in project goci by EBISPOT.
the class StudyUpdateService method checkForEfoTraitUpdate.
private String checkForEfoTraitUpdate(List<String> existingStudyEfoTraits, List<String> updatedStudyEfoTraits) {
// Sort traits
List<String> existingStudyEfoTraitsSorted = existingStudyEfoTraits.stream().sorted().collect(Collectors.toList());
List<String> updatedStudyEfoTraitsSorted = updatedStudyEfoTraits.stream().sorted().collect(Collectors.toList());
// Create a string version of each list of traits
String existingStudyEfoTraitsAsString = null;
if (!existingStudyEfoTraitsSorted.isEmpty()) {
StringJoiner existingJoiner = new StringJoiner(", ");
existingStudyEfoTraitsSorted.forEach(s -> existingJoiner.add(s));
existingStudyEfoTraitsAsString = existingJoiner.toString();
}
String updatedStudyEfoTraitsAsString = null;
if (!updatedStudyEfoTraitsSorted.isEmpty()) {
StringJoiner updateJoiner = new StringJoiner(", ");
updatedStudyEfoTraitsSorted.stream().forEach(s -> updateJoiner.add(s));
updatedStudyEfoTraitsAsString = updateJoiner.toString();
}
return attributeUpdateService.compareAttribute("EFO Trait", existingStudyEfoTraitsAsString, updatedStudyEfoTraitsAsString);
}
use of java.util.StringJoiner in project goci by EBISPOT.
the class AssociationValidationReportService method getWarningSet.
/**
* Retrieve validation warnings for an association and return unique set
*
* @param associationId ID of association to get warning for
*/
public Set<String> getWarningSet(Long associationId) {
Set<String> warnings = new HashSet<>();
associationValidationReportRepository.findByAssociationId(associationId).forEach(associationValidationReport -> {
StringJoiner warningJoiner = new StringJoiner(": ");
warningJoiner.add(associationValidationReport.getValidatedField());
warningJoiner.add(associationValidationReport.getWarning());
warnings.add(warningJoiner.toString());
});
return warnings;
}
use of java.util.StringJoiner in project goci by EBISPOT.
the class AssociationEventsViewService method createViews.
@Override
public List<EventView> createViews(Long studyId) {
List<EventView> views = new ArrayList<>();
Collection<Association> associations = studyRepository.findOne(studyId).getAssociations();
if (!associations.isEmpty()) {
// For each association gather up the events into a collection of views
associations.forEach(association -> {
Collection<Event> events = association.getEvents();
Long associationId = association.getId();
Collection<SingleNucleotidePolymorphism> snps = singleNucleotidePolymorphismRepository.findByRiskAllelesLociAssociationId(associationId);
String associationSummary;
StringJoiner snpJoiner = new StringJoiner(", ");
snps.forEach(singleNucleotidePolymorphism -> {
snpJoiner.add(singleNucleotidePolymorphism.getRsId());
});
associationSummary = snpJoiner.toString();
events.forEach(event -> {
String eventName = eventTypeService.translateEventByEventType(event.getEventType());
EventView eventView = new AssociationEventView(eventName, event.getEventDate(), associationId, event.getUser().getEmail(), associationSummary);
views.add(eventView);
});
});
}
return views;
}
use of java.util.StringJoiner in project intellij-community by JetBrains.
the class JavaFxColorProvider method getCallText.
@NotNull
private static String getCallText(@NotNull Color color, String colorMethodName, String grayMethodName, IntFunction<String> formatter) {
String methodName;
StringJoiner args = new StringJoiner(",", "(", ")");
if (color.getRed() == color.getGreen() && color.getRed() == color.getBlue()) {
methodName = grayMethodName;
args.add(formatter.apply(color.getRed()));
} else {
methodName = colorMethodName;
args.add(formatter.apply(color.getRed()));
args.add(formatter.apply(color.getGreen()));
args.add(formatter.apply(color.getBlue()));
}
if (color.getAlpha() != 255) {
args.add(formatScaledComponent(color.getAlpha()));
}
return methodName + args;
}
Aggregations