Skip to content

Commit

Permalink
Merge pull request #25 from jmmut/feature/reduce-document
Browse files Browse the repository at this point in the history
EVA-1251 Reduce size of MongoDB documents
  • Loading branch information
Cristina Yenyxe Gonzalez Garcia authored Jun 19, 2018
2 parents 5442086 + a684516 commit 61f2782
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.config.EnableMongoAuditing;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import java.net.UnknownHostException;
Expand Down Expand Up @@ -56,4 +60,10 @@ public MongoClient mongoClient(MongoProperties properties, ObjectProvider<MongoC
return properties.createMongoClient(mongoClientOptions, environment);
}

@Bean
public MongoTemplate mongoTemplate(MongoDbFactory mongoDbFactory,
MappingMongoConverter converter) throws UnknownHostException {
converter.setTypeMapper(new DefaultMongoTypeMapper(null));
return new MongoTemplate(mongoDbFactory, converter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package uk.ac.ebi.eva.accession.core.persistence;

import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import uk.ac.ebi.ampt2d.commons.accession.persistence.mongodb.document.AccessionedDocument;

import uk.ac.ebi.eva.accession.core.ISubmittedVariant;
Expand All @@ -27,20 +28,26 @@
@Document
public class SubmittedVariantEntity extends AccessionedDocument<Long> implements ISubmittedVariant {

@Field("asm")
private String assemblyAccession;

@Field("tax")
private int taxonomyAccession;

@Field("study")
private String projectAccession;

private String contig;

private long start;

@Field("ref")
private String referenceAllele;

@Field("alt")
private String alternateAllele;

@Field("evidence")
private boolean supportedByEvidence;

SubmittedVariantEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ public void testSaveInitializesCreatedDate() throws Exception {
"reference", "alternate", false);
LocalDateTime beforeSave = LocalDateTime.now();
accessionWriter.write(Collections.singletonList(variant));
LocalDateTime afterSave = LocalDateTime.now();

List<AccessionWrapper<ISubmittedVariant, String, Long>> accessions = service.get(Collections.singletonList(variant));
assertEquals(1, accessions.size());
ISubmittedVariant savedVariant = accessions.iterator().next().getData();
assertTrue(beforeSave.isBefore(savedVariant.getCreatedDate()));
assertTrue(afterSave.isAfter(savedVariant.getCreatedDate()));
}

@Test
Expand Down

0 comments on commit 61f2782

Please sign in to comment.