Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-4158
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga authored Feb 6, 2024
2 parents 3c256ba + 255a2df commit 946755f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void fillSamples(String studyId, List<org.opencb.biodata.models.metadata
if (annotationSets != null) {
sample.setAnnotations(new LinkedHashMap<>(sample.getAnnotations()));
for (AnnotationSet annotationSet : annotationSets) {
String prefix = annotationSets.size() > 1 ? annotationSet.getName() + '.' : "";
String prefix = annotationSets.size() > 1 ? annotationSet.getId() + '.' : "";
Map<String, Object> annotations = annotationSet.getAnnotations();
for (Map.Entry<String, Object> annotationEntry : annotations.entrySet()) {
Object value = annotationEntry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public List<AnnotationSet> fromDBToAnnotation(List<Document> annotationList, Doc
String variableSetId = variableSetUidIdMap.getString(String.valueOf(variableSetUid));

if (!annotationSetMap.containsKey(compoundKey)) {
annotationSetMap.put(compoundKey, new AnnotationSet(annSetName, variableSetId, new HashMap<>(),
Collections.emptyMap()));
annotationSetMap.put(compoundKey, new AnnotationSet(annSetName, variableSetId, new HashMap<>()));
}

annotationSetMap.get(compoundKey).getAnnotations().put(annotationDocument.getString(ID), annotationDocument.get(VALUE));
Expand All @@ -203,8 +202,7 @@ public List<AnnotationSet> fromDBToAnnotation(List<Document> annotationList, Doc
String variableSetId = variableSetUidIdMap.getString(String.valueOf(variableSetUid));

if (!annotationSetMap.containsKey(compoundKey)) {
annotationSetMap.put(compoundKey, new AnnotationSet(annSetName, variableSetId, new HashMap<>(),
Collections.emptyMap()));
annotationSetMap.put(compoundKey, new AnnotationSet(annSetName, variableSetId, new HashMap<>()));
}

// We provide the map from the annotation set in order to be automatically filled in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ public static void checkVariable(Variable variable) throws CatalogException {
throw new CatalogException("Only variables with type \"OBJECT\" can define an internal variableSet");
}

if (variable.getType() == Variable.VariableType.TEXT) {
variable.setType(Variable.VariableType.STRING);
}

//Check default values
switch (variable.getType()) {
case BOOLEAN:
Expand Down Expand Up @@ -431,7 +427,7 @@ private static void checkAllowedValue(Variable variable, Object value, String me
Map objectMap = (Map) object;
checkAnnotationSet(new VariableSet(variable.getId(), variable.getId(), false, false, false,
variable.getDescription(), variable.getVariables(), null, 1, null),
new AnnotationSet("", variable.getId(), objectMap, null, 1, null), null, true);
new AnnotationSet("", variable.getId(), objectMap), null, true);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public DataResult<Sample> loadSampleAnnotations(File pedFile, String variableSet
for (Individual individual : ped.getIndividuals().values()) {
Map<String, Object> annotation = getAnnotation(individual, sampleMap, variableSet, ped.getFields());
try {
AnnotationUtils.checkAnnotationSet(variableSet, new AnnotationSet("", variableSet.getId(), annotation, "", 1,
null), null, true);
AnnotationUtils.checkAnnotationSet(variableSet, new AnnotationSet("", variableSet.getId(), annotation), null, true);
} catch (CatalogException e) {
String message = "Validation with the variableSet {id: " + variableSetId + "} over ped File = {path: " + pedFile.getPath()
+ ", name: \"" + pedFile.getName() + "\"} failed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void mergeAnnotationsTest() {
annotations.put("K", "V");
annotations.put("K2", "V2");
annotations.put("K4", false);
AnnotationSet annotationSet = new AnnotationSet("", "", annotations, "", 1, Collections.emptyMap());
AnnotationSet annotationSet = new AnnotationSet("", "", annotations);
Map<String, Object> newAnnotations = new ObjectMap()
.append("K", "newValue") //Modify
.append("K2", null) //Delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ public void testLoadPedigreeCatalog() throws Exception {
private void validate(Pedigree pedigree, VariableSet variableSet) throws CatalogException {
for (Map.Entry<String, Individual> entry : pedigree.getIndividuals().entrySet()) {
Map<String, Object> annotation = loader.getAnnotation(entry.getValue(), null, variableSet, pedigree.getFields());
AnnotationUtils.checkAnnotationSet(variableSet, new AnnotationSet("", variableSet.getId(), annotation, "", 1,
null), null, true);
AnnotationUtils.checkAnnotationSet(variableSet, new AnnotationSet("", variableSet.getId(), annotation), null, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@

package org.opencb.opencga.core.models.common;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.opencb.opencga.core.common.JacksonUtils;
import org.opencb.opencga.core.common.TimeUtils;

import java.util.Collections;
import java.util.Map;

/**
Expand All @@ -31,38 +28,16 @@
public class AnnotationSet {

private String id;
@Deprecated
private String name;
private String variableSetId;
private Map<String, Object> annotations;
@Deprecated
private String creationDate;
@Deprecated
private int release;
@Deprecated
private Map<String, Object> attributes;


public AnnotationSet() {
}

public AnnotationSet(String id, String variableSetId, Map<String, Object> annotations) {
this(id, variableSetId, annotations, TimeUtils.getTime(), 1, Collections.emptyMap());
}

public AnnotationSet(String id, String variableSetId, Map<String, Object> annotations, Map<String, Object> attributes) {
this(id, variableSetId, annotations, TimeUtils.getTime(), 1, attributes);
}

public AnnotationSet(String id, String variableSetId, Map<String, Object> annotations, String creationDate, int release,
Map<String, Object> attributes) {
this.id = id;
this.name = id;
this.variableSetId = variableSetId;
this.annotations = annotations;
this.creationDate = creationDate;
this.release = release;
this.attributes = attributes;
}

@Override
Expand All @@ -71,9 +46,6 @@ public String toString() {
sb.append("id='").append(id).append('\'');
sb.append(", variableSetId=").append(variableSetId);
sb.append(", annotations=").append(annotations);
sb.append(", creationDate='").append(creationDate).append('\'');
sb.append(", release=").append(release);
sb.append(", attributes=").append(attributes);
sb.append('}');
return sb.toString();
}
Expand All @@ -89,15 +61,13 @@ public boolean equals(Object o) {
}

AnnotationSet that = (AnnotationSet) o;
return new EqualsBuilder().append(variableSetId, that.variableSetId).append(release, that.release).append(id, that.id)
.append(annotations, that.annotations).append(creationDate, that.creationDate).append(attributes, that.attributes)
return new EqualsBuilder().append(variableSetId, that.variableSetId).append(id, that.id).append(annotations, that.annotations)
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(id).append(variableSetId).append(annotations).append(creationDate).append(release)
.append(attributes).toHashCode();
return new HashCodeBuilder(17, 37).append(id).append(variableSetId).append(annotations).toHashCode();
}

public String getId() {
Expand All @@ -106,17 +76,6 @@ public String getId() {

public AnnotationSet setId(String id) {
this.id = id;
this.name = StringUtils.isEmpty(this.name) ? this.id : this.name;
return this;
}

public String getName() {
return name;
}

public AnnotationSet setName(String name) {
this.name = name;
this.id = StringUtils.isEmpty(this.id) ? this.name : this.id;
return this;
}

Expand All @@ -138,33 +97,6 @@ public AnnotationSet setAnnotations(Map<String, Object> annotations) {
return this;
}

public String getCreationDate() {
return creationDate;
}

public AnnotationSet setCreationDate(String creationDate) {
this.creationDate = creationDate;
return this;
}

public int getRelease() {
return release;
}

public AnnotationSet setRelease(int release) {
this.release = release;
return this;
}

public Map<String, Object> getAttributes() {
return attributes;
}

public AnnotationSet setAttributes(Map<String, Object> attributes) {
this.attributes = attributes;
return this;
}

public <T> T to(Class<T> tClass) {
return JacksonUtils.getDefaultObjectMapper().convertValue(this.getAnnotations(), tClass);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ public class Variable {
private long rank;
private String dependsOn;
private String description;
/**
* Variables for validate internal fields. Only valid if type is OBJECT.
**/
@Deprecated
private Set<Variable> variableSet;

private Set<Variable> variables;
private Map<String, Object> attributes;

Expand Down Expand Up @@ -90,8 +86,6 @@ public enum VariableType {
CATEGORICAL,
INTEGER,
DOUBLE,
@Deprecated
TEXT,
STRING,
OBJECT,
MAP_BOOLEAN,
Expand Down Expand Up @@ -229,16 +223,6 @@ public Variable setDescription(String description) {
return this;
}

@Deprecated
public Set<Variable> getVariableSet() {
return getVariables();
}

@Deprecated
public Variable setVariableSet(Set<Variable> variableSet) {
return setVariables(variableSet);
}

public Set<Variable> getVariables() {
return variables;
}
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
-->
<sonar.scanner.force-deprecated-java-version>true</sonar.scanner.force-deprecated-java-version>
<kryo.version>2.23.0</kryo.version>

<lombok.version>1.18.30</lombok.version>
<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
</properties>
Expand Down

0 comments on commit 946755f

Please sign in to comment.