Skip to content

Commit

Permalink
Select contacts (#464)
Browse files Browse the repository at this point in the history
* add selection component to project edit form

* Fix ontology column size and type

* Fix ontology column size and type

* provide prefill for add project as well

complicated setup of add project made this difficult. further refactoring might be needed.

* Fix stepper

* introduce HasBinder interface

* fix dialog validation and scope

Co-authored-by: steffengreiner <[email protected]>

* Add JavaDoc

* Use HasBinderValidation for AutocompleteContactField

* add javadoc

* Fix field title

* Remove unused methods

* "Fix" column names.

These should be adapted in the future. Using the plural for singular column is not good IMHO.

* Adjust terms used to fit the database

* Improve JavaDoc

Co-authored-by: steffengreiner <[email protected]>

* Add placeholder

Co-authored-by: steffengreiner <[email protected]>

* do not require the view object to contain data

* remove hard-coded 100 width and height

* remove unused annotation

* add error message to requireNonNull

* move page size to css

* Fix wrong mapping

Co-authored-by: steffengreiner <[email protected]>

---------

Co-authored-by: Tobias Koch <[email protected]>
Co-authored-by: steffengreiner <[email protected]>
  • Loading branch information
3 people authored Jan 25, 2024
1 parent 18691f5 commit 8bab447
Show file tree
Hide file tree
Showing 33 changed files with 1,057 additions and 932 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ public List<OntologyClassEntity> query(int offset, int limit) {
private String buildSearchTerm(String searchString) {
StringBuilder searchTermBuilder = new StringBuilder();
for(String word : searchString.split(" ")) {
searchTermBuilder.append(" +" + word);
searchTermBuilder.append(" +").append(word);
}
searchTermBuilder.append("*");
return searchTermBuilder.toString().trim();
}

@Override
public List<OntologyClassEntity> query(String searchString, List<String> ontologyAbbreviations,
public List<OntologyClassEntity> query(String searchString,
List<String> ontologyAbbreviations,
int offset,
int limit, List<SortOrder> sortOrders) {
List<Order> orders = sortOrders.stream().map(it -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ public interface OntologyTermRepository extends
countQuery = "SELECT count(*) FROM ontology_classes WHERE MATCH(label) AGAINST(?1 IN BOOLEAN MODE) AND ontology in (?2);",
nativeQuery = true)
Page<OntologyClassEntity> findByLabelFulltextMatching(
String termFilter, List<String> ontology, Pageable pageable);

Page<OntologyClassEntity> findByLabelNotNullAndOntologyIn(List<String> ontologies, Pageable pageable);

Page<OntologyClassEntity> findByLabelStartingWithIgnoreCaseAndOntologyIn(String filter, List<String> ontology, Pageable pageable);
String termFilter, List<String> ontologyAbbreviations, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public OntologyTermRepositoryImpl(QbicOntologyTermRepo ontologyTermRepo) {

@Override
public List<OntologyClassEntity> find(String name) {
return ontologyTermRepo.findOntologyTermByName(name);
return ontologyTermRepo.findOntologyClassEntitiesByClassName(name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
*/
public interface QbicOntologyTermRepo extends CrudRepository<OntologyClassEntity, Long> {

List<OntologyClassEntity> findOntologyTermByName(String name);
List<OntologyClassEntity> findOntologyClassEntitiesByClassName(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package life.qbic.projectmanagement.application;

import java.util.List;
import life.qbic.projectmanagement.domain.model.project.Contact;
import org.springframework.stereotype.Component;

@Component
public class ContactRepository {

public List<Contact> findAll() {
//TODO implement
return dummyContacts();
}

private static List<Contact> dummyContacts() {
return List.of(
new Contact("Max Mustermann", "[email protected]"),
new Contact("David Müller", "[email protected]"),
new Contact("John Koch", "[email protected]"),
new Contact("Trevor Noah", "[email protected]"),
new Contact("Sarah Connor", "[email protected]"),
new Contact("Anna Bell", "[email protected]"),
new Contact("Sophia Turner", "[email protected]"),
new Contact("Tylor Smith", "[email protected]")
);
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package life.qbic.projectmanagement.application;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
Expand All @@ -10,18 +11,19 @@
@Table(name = "ontology_classes")
public class OntologyClassEntity {

String ontology;

@Column(name = "ontology")
String ontologyAbbreviation;
@Column(name = "ontologyVersion")
String ontologyVersion;

@Column(name = "ontologyIri")
String ontologyIri;

String label;

String name;

@Column(name = "label")
String classLabel;
@Column(name = "name")
String className;
@Column(name = "description", length = 2000)
String description;

@Column(name = "classIri")
String classIri;

@Id
Expand All @@ -31,23 +33,24 @@ public class OntologyClassEntity {
public OntologyClassEntity() {
}

public OntologyClassEntity(String ontology, String ontologyVersion, String ontologyIri,
String label, String name, String description, String classIri) {
this.ontology = ontology;
public OntologyClassEntity(String ontologyAbbreviation, String ontologyVersion,
String ontologyIri,
String classLabel, String className, String description, String classIri) {
this.ontologyAbbreviation = ontologyAbbreviation;
this.ontologyVersion = ontologyVersion;
this.ontologyIri = ontologyIri;
this.label = label;
this.name = name;
this.classLabel = classLabel;
this.className = className;
this.description = description;
this.classIri = classIri;
}

public String getOntology() {
return ontology;
public String getOntologyAbbreviation() {
return ontologyAbbreviation;
}

public void setOntology(String ontology) {
this.ontology = ontology;
public void setOntologyAbbreviation(String ontology) {
this.ontologyAbbreviation = ontology;
}

public String getOntologyVersion() {
Expand All @@ -66,20 +69,20 @@ public void setOntologyIri(String ontologyIri) {
this.ontologyIri = ontologyIri;
}

public String getLabel() {
return label;
public String getClassLabel() {
return classLabel;
}

public void setLabel(String label) {
this.label = label;
public void setClassLabel(String label) {
this.classLabel = label;
}

public String getName() {
return name;
public String getClassName() {
return className;
}

public void setName(String name) {
this.name = name;
public void setClassName(String name) {
this.className = name;
}

public String getDescription() {
Expand Down Expand Up @@ -107,16 +110,17 @@ public boolean equals(Object o) {
return false;
}
OntologyClassEntity that = (OntologyClassEntity) o;
return Objects.equals(ontology, that.ontology) && Objects.equals(
return Objects.equals(ontologyAbbreviation, that.ontologyAbbreviation) && Objects.equals(
ontologyVersion, that.ontologyVersion) && Objects.equals(ontologyIri,
that.ontologyIri) && Objects.equals(label, that.label) && Objects.equals(
name, that.name) && Objects.equals(description, that.description)
that.ontologyIri) && Objects.equals(classLabel, that.classLabel) && Objects.equals(
className, that.className) && Objects.equals(description, that.description)
&& Objects.equals(classIri, that.classIri);
}

@Override
public int hashCode() {
return Objects.hash(ontology, ontologyVersion, ontologyIri, label, name, description, classIri);
return Objects.hash(ontologyAbbreviation, ontologyVersion, ontologyIri, classLabel, className,
description, classIri);
}

public Long getId() {
Expand All @@ -126,4 +130,4 @@ public Long getId() {
public void setId(Long id) {
this.id = id;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public List<OntologyClassEntity> queryOntologyTerm(String termFilter, List<Strin
int offset, int limit, List<SortOrder> sortOrders) {
// returned by JPA -> UnmodifiableRandomAccessList
List<OntologyClassEntity> termList = ontologyTermLookup.query(termFilter, ontologyAbbreviations, offset,
50, sortOrders);
limit, sortOrders);
// the list must be modifiable for spring security to filter it
return new ArrayList<>(termList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Embedded;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.util.Objects;
import life.qbic.projectmanagement.domain.model.Ontology;
import life.qbic.projectmanagement.domain.model.batch.Batch;
import life.qbic.projectmanagement.domain.model.experiment.BiologicalReplicate;
import life.qbic.projectmanagement.domain.model.experiment.Experiment;
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
import life.qbic.projectmanagement.domain.model.experiment.ExperimentalGroup;
import life.qbic.projectmanagement.domain.model.experiment.repository.jpa.OntologyClassAttributeConverter;
import life.qbic.projectmanagement.domain.model.experiment.vocabulary.OntologyClassDTO;
import life.qbic.projectmanagement.domain.model.sample.Sample;
import life.qbic.projectmanagement.domain.model.sample.SampleCode;
Expand Down Expand Up @@ -54,11 +51,8 @@ public class SamplePreview {
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "experimentalGroupId")
private ExperimentalGroup experimentalGroup;
@Convert(converter = OntologyClassAttributeConverter.class)
private OntologyClassDTO species;
@Convert(converter = OntologyClassAttributeConverter.class)
private OntologyClassDTO specimen;
@Convert(converter = OntologyClassAttributeConverter.class)
private OntologyClassDTO analyte;

protected SamplePreview() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package life.qbic.projectmanagement.domain.model.experiment;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Embedded;
import jakarta.persistence.EmbeddedId;
Expand All @@ -18,7 +17,6 @@
import life.qbic.projectmanagement.domain.model.experiment.exception.ConditionExistsException;
import life.qbic.projectmanagement.domain.model.experiment.exception.ExperimentalVariableExistsException;
import life.qbic.projectmanagement.domain.model.experiment.exception.ExperimentalVariableNotDefinedException;
import life.qbic.projectmanagement.domain.model.experiment.repository.jpa.OntologyClassAttributeConverter;
import life.qbic.projectmanagement.domain.model.experiment.vocabulary.OntologyClassDTO;


Expand All @@ -43,13 +41,15 @@ public class Experiment {
private ExperimentalDesign experimentalDesign;

@ElementCollection(targetClass = OntologyClassDTO.class)
@Convert(converter = OntologyClassAttributeConverter.class)
@Column(name = "analytes", columnDefinition = "longtext CHECK (json_valid(`analyte`))")
//FIXME should be `analyte`in the database and here
private List<OntologyClassDTO> analytes = new ArrayList<>();
@ElementCollection(targetClass = OntologyClassDTO.class)
@Convert(converter = OntologyClassAttributeConverter.class)
@Column(name = "species", columnDefinition = "longtext CHECK (json_valid(`species`))")
private List<OntologyClassDTO> species = new ArrayList<>();
@ElementCollection(targetClass = OntologyClassDTO.class)
@Convert(converter = OntologyClassAttributeConverter.class)
@Column(name = "specimens", columnDefinition = "longtext CHECK (json_valid(`specimen`))")
//FIXME should be `specimen`in the database and here
private List<OntologyClassDTO> specimens = new ArrayList<>();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import jakarta.persistence.Converter;
import life.qbic.projectmanagement.domain.model.experiment.vocabulary.OntologyClassDTO;

@Converter()
public class OntologyClassAttributeConverter implements AttributeConverter<OntologyClassDTO,
String> {
@Converter(autoApply = true)

public class OntologyClassAttributeConverter implements
AttributeConverter<OntologyClassDTO, String> {

private static final ObjectMapper objectMapper = new ObjectMapper();

Expand All @@ -23,11 +24,11 @@ public String convertToDatabaseColumn(OntologyClassDTO attribute) {

@Override
public OntologyClassDTO convertToEntityAttribute(String dbData) {
try {
return objectMapper.readValue(dbData, OntologyClassDTO.class);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
try {
return objectMapper.readValue(dbData, OntologyClassDTO.class);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}

}
Loading

0 comments on commit 8bab447

Please sign in to comment.