Search in sources :

Example 66 with StringJoiner

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;
}
Also used : ArrayList(java.util.ArrayList) StringJoiner(java.util.StringJoiner)

Example 67 with StringJoiner

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);
}
Also used : StringJoiner(java.util.StringJoiner)

Example 68 with StringJoiner

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;
}
Also used : StringJoiner(java.util.StringJoiner) HashSet(java.util.HashSet)

Example 69 with StringJoiner

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;
}
Also used : ArrayList(java.util.ArrayList) AssociationEventView(uk.ac.ebi.spot.goci.curation.model.AssociationEventView) EventView(uk.ac.ebi.spot.goci.curation.model.EventView) Association(uk.ac.ebi.spot.goci.model.Association) AssociationEventView(uk.ac.ebi.spot.goci.curation.model.AssociationEventView) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Event(uk.ac.ebi.spot.goci.model.Event) StringJoiner(java.util.StringJoiner)

Example 70 with StringJoiner

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;
}
Also used : StringJoiner(java.util.StringJoiner) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StringJoiner (java.util.StringJoiner)98 ArrayList (java.util.ArrayList)22 List (java.util.List)11 IOException (java.io.IOException)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 ClassName (com.squareup.javapoet.ClassName)3 FieldSpec (com.squareup.javapoet.FieldSpec)3 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)3 TypeName (com.squareup.javapoet.TypeName)3 TypeSpec (com.squareup.javapoet.TypeSpec)3 Expression (com.sri.ai.expresso.api.Expression)3 Attribute (io.requery.meta.Attribute)3 Field (java.lang.reflect.Field)3 Scanner (java.util.Scanner)3 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)2 Range (com.facebook.presto.spi.predicate.Range)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2