Skip to content

Commit

Permalink
Add modification date to study (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgaldi authored Apr 28, 2023
1 parent f4b9bbf commit f86064a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Study extends StudyOverview {
private final Map<String, Entity> _entityIdMap;

public Study(StudyOverview overview, TreeNode<Entity> entityTree, Map<String, Entity> entityIdMap) {
super(overview.getStudyId(), overview.getInternalAbbrev(), overview.getStudySourceType());
super(overview.getStudyId(), overview.getInternalAbbrev(), overview.getStudySourceType(), overview.getLastModified());
_entityTree = entityTree;
_entityIdMap = entityIdMap;
initEntities(entityTree);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.veupathdb.service.eda.ss.model;

import java.util.Date;

/* a brief version of the study */
public class StudyOverview {

Expand All @@ -11,11 +13,16 @@ public enum StudySourceType {
private final String id;
private final String internalAbbrev;
private final StudySourceType studySourceType;
private final Date lastModified;

public StudyOverview(String id, String internalAbbrev, StudySourceType studySourceType) {
public StudyOverview(String id,
String internalAbbrev,
StudySourceType studySourceType,
Date lastModified) {
this.id = id;
this.internalAbbrev = internalAbbrev;
this.studySourceType = studySourceType;
this.lastModified = lastModified;
}

public String getStudyId() {
Expand All @@ -29,4 +36,8 @@ public String getInternalAbbrev() {
public StudySourceType getStudySourceType() {
return studySourceType;
}

public Date getLastModified() {
return lastModified;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Study {
interface Columns extends ColumnCollection {
String STUDY_ID_COL_NAME = "stable_id";
String STUDY_ABBREV_COL_NAME = "internal_abbrev";
String STUDY_DATE_MODIFIED_COL_NAME = "modification_date";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
import org.veupathdb.service.eda.ss.model.Study;
import org.veupathdb.service.eda.ss.model.StudyOverview;
import org.veupathdb.service.eda.ss.model.StudyOverview.StudySourceType;
import org.veupathdb.service.eda.ss.model.reducer.BinaryMetadataProvider;
import org.veupathdb.service.eda.ss.model.variable.binary.BinaryFilesManager;

import javax.sql.DataSource;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_ABBREV_COL_NAME;
import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_DATE_MODIFIED_COL_NAME;
import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_ID_COL_NAME;

public class StudyFactory implements StudyProvider {
Expand All @@ -40,7 +41,7 @@ public StudyFactory(DataSource dataSource,
}

private static String getStudyOverviewSql(String appDbSchema) {
return "select s." + STUDY_ID_COL_NAME + ", s." + STUDY_ABBREV_COL_NAME +
return "select s." + STUDY_ID_COL_NAME + ", s." + STUDY_ABBREV_COL_NAME + ", s." + STUDY_DATE_MODIFIED_COL_NAME +
" from " + appDbSchema + DB.Tables.Study.NAME + " s ";
}

Expand All @@ -52,7 +53,8 @@ public List<StudyOverview> getStudyOverviews() {
while (rs.next()) {
String id = rs.getString(1);
String abbrev = rs.getString(2);
StudyOverview study = new StudyOverview(id, abbrev, _sourceType);
Date lastModified = rs.getDate(3);
StudyOverview study = new StudyOverview(id, abbrev, _sourceType, lastModified);
studyOverviews.add(study);
}
return studyOverviews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.veupathdb.service.eda.ss.model.distribution.DateDistributionConfig;
import org.veupathdb.service.eda.ss.model.distribution.NumberDistributionConfig;
import org.veupathdb.service.eda.ss.model.variable.*;
import org.veupathdb.service.eda.ss.model.variable.binary.EmptyBinaryProperties;

import java.util.*;

Expand Down Expand Up @@ -42,7 +41,7 @@ public class MockModel {

public MockModel() {
createTestEntities();
StudyOverview overview = new StudyOverview("GEMS", "ds2324", StudyOverview.StudySourceType.CURATED);
StudyOverview overview = new StudyOverview("GEMS", "ds2324", StudyOverview.StudySourceType.CURATED, new Date());
study = new Study(overview, constructEntityTree(), createIdMap());
constructVariables();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ create table Study (
stable_id varchar(50) not null,
display_name varchar(30) not null,
internal_abbrev varchar(30),
modification_date date,
PRIMARY KEY (stable_id)
);
alter table Study add unique (display_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
------------------------------------------------------------

--(stable_id, display_nme, internal_abbrev)
insert into study values ('DS-2324', 'GEMS', 'ds2324');
insert into study values ('DS-2324', 'GEMS', 'ds2324', '2023-01-01');

insert into StudyIdDatasetId values('DS-2324', 'datasetid_2222');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.veupathdb.service.eda.ss.model.variable.*;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -72,7 +73,7 @@ public StudyBuilder addEntity(Entity entity, String parentId) {
}

public Study build() {
final StudyOverview studyOverview = new StudyOverview(studyId, internalAbbrev, StudyOverview.StudySourceType.CURATED);
final StudyOverview studyOverview = new StudyOverview(studyId, internalAbbrev, StudyOverview.StudySourceType.CURATED, new Date());
return new Study(studyOverview, rootEntity, entityIdMap);
}

Expand Down

0 comments on commit f86064a

Please sign in to comment.