Skip to content

Commit f86064a

Browse files
authored
Add modification date to study (#25)
1 parent f4b9bbf commit f86064a

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

src/main/java/org/veupathdb/service/eda/ss/model/Study.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Study extends StudyOverview {
1414
private final Map<String, Entity> _entityIdMap;
1515

1616
public Study(StudyOverview overview, TreeNode<Entity> entityTree, Map<String, Entity> entityIdMap) {
17-
super(overview.getStudyId(), overview.getInternalAbbrev(), overview.getStudySourceType());
17+
super(overview.getStudyId(), overview.getInternalAbbrev(), overview.getStudySourceType(), overview.getLastModified());
1818
_entityTree = entityTree;
1919
_entityIdMap = entityIdMap;
2020
initEntities(entityTree);

src/main/java/org/veupathdb/service/eda/ss/model/StudyOverview.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.veupathdb.service.eda.ss.model;
22

3+
import java.util.Date;
4+
35
/* a brief version of the study */
46
public class StudyOverview {
57

@@ -11,11 +13,16 @@ public enum StudySourceType {
1113
private final String id;
1214
private final String internalAbbrev;
1315
private final StudySourceType studySourceType;
16+
private final Date lastModified;
1417

15-
public StudyOverview(String id, String internalAbbrev, StudySourceType studySourceType) {
18+
public StudyOverview(String id,
19+
String internalAbbrev,
20+
StudySourceType studySourceType,
21+
Date lastModified) {
1622
this.id = id;
1723
this.internalAbbrev = internalAbbrev;
1824
this.studySourceType = studySourceType;
25+
this.lastModified = lastModified;
1926
}
2027

2128
public String getStudyId() {
@@ -29,4 +36,8 @@ public String getInternalAbbrev() {
2936
public StudySourceType getStudySourceType() {
3037
return studySourceType;
3138
}
39+
40+
public Date getLastModified() {
41+
return lastModified;
42+
}
3243
}

src/main/java/org/veupathdb/service/eda/ss/model/db/DB.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface Study {
2020
interface Columns extends ColumnCollection {
2121
String STUDY_ID_COL_NAME = "stable_id";
2222
String STUDY_ABBREV_COL_NAME = "internal_abbrev";
23+
String STUDY_DATE_MODIFIED_COL_NAME = "modification_date";
2324
}
2425
}
2526

src/main/java/org/veupathdb/service/eda/ss/model/db/StudyFactory.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
import org.veupathdb.service.eda.ss.model.Study;
99
import org.veupathdb.service.eda.ss.model.StudyOverview;
1010
import org.veupathdb.service.eda.ss.model.StudyOverview.StudySourceType;
11-
import org.veupathdb.service.eda.ss.model.reducer.BinaryMetadataProvider;
12-
import org.veupathdb.service.eda.ss.model.variable.binary.BinaryFilesManager;
1311

1412
import javax.sql.DataSource;
13+
import java.time.Instant;
1514
import java.util.ArrayList;
15+
import java.util.Date;
1616
import java.util.List;
1717
import java.util.Map;
1818
import java.util.stream.Collectors;
1919

2020
import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_ABBREV_COL_NAME;
21+
import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_DATE_MODIFIED_COL_NAME;
2122
import static org.veupathdb.service.eda.ss.model.db.DB.Tables.Study.Columns.STUDY_ID_COL_NAME;
2223

2324
public class StudyFactory implements StudyProvider {
@@ -40,7 +41,7 @@ public StudyFactory(DataSource dataSource,
4041
}
4142

4243
private static String getStudyOverviewSql(String appDbSchema) {
43-
return "select s." + STUDY_ID_COL_NAME + ", s." + STUDY_ABBREV_COL_NAME +
44+
return "select s." + STUDY_ID_COL_NAME + ", s." + STUDY_ABBREV_COL_NAME + ", s." + STUDY_DATE_MODIFIED_COL_NAME +
4445
" from " + appDbSchema + DB.Tables.Study.NAME + " s ";
4546
}
4647

@@ -52,7 +53,8 @@ public List<StudyOverview> getStudyOverviews() {
5253
while (rs.next()) {
5354
String id = rs.getString(1);
5455
String abbrev = rs.getString(2);
55-
StudyOverview study = new StudyOverview(id, abbrev, _sourceType);
56+
Date lastModified = rs.getDate(3);
57+
StudyOverview study = new StudyOverview(id, abbrev, _sourceType, lastModified);
5658
studyOverviews.add(study);
5759
}
5860
return studyOverviews;

src/main/java/org/veupathdb/service/eda/ss/test/MockModel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.veupathdb.service.eda.ss.model.distribution.DateDistributionConfig;
88
import org.veupathdb.service.eda.ss.model.distribution.NumberDistributionConfig;
99
import org.veupathdb.service.eda.ss.model.variable.*;
10-
import org.veupathdb.service.eda.ss.model.variable.binary.EmptyBinaryProperties;
1110

1211
import java.util.*;
1312

@@ -42,7 +41,7 @@ public class MockModel {
4241

4342
public MockModel() {
4443
createTestEntities();
45-
StudyOverview overview = new StudyOverview("GEMS", "ds2324", StudyOverview.StudySourceType.CURATED);
44+
StudyOverview overview = new StudyOverview("GEMS", "ds2324", StudyOverview.StudySourceType.CURATED, new Date());
4645
study = new Study(overview, constructEntityTree(), createIdMap());
4746
constructVariables();
4847
}

src/main/resources/org/veupathdb/service/eda/ss/stubdb/createDbSchema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ create table Study (
99
stable_id varchar(50) not null,
1010
display_name varchar(30) not null,
1111
internal_abbrev varchar(30),
12+
modification_date date,
1213
PRIMARY KEY (stable_id)
1314
);
1415
alter table Study add unique (display_name);

src/main/resources/org/veupathdb/service/eda/ss/stubdb/insertDbData.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
------------------------------------------------------------
1111

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

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

src/test/java/org/veupathdb/service/eda/ss/testutil/TestDataProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.veupathdb.service.eda.ss.model.variable.*;
1010

1111
import java.util.Collections;
12+
import java.util.Date;
1213
import java.util.HashMap;
1314
import java.util.Map;
1415

@@ -72,7 +73,7 @@ public StudyBuilder addEntity(Entity entity, String parentId) {
7273
}
7374

7475
public Study build() {
75-
final StudyOverview studyOverview = new StudyOverview(studyId, internalAbbrev, StudyOverview.StudySourceType.CURATED);
76+
final StudyOverview studyOverview = new StudyOverview(studyId, internalAbbrev, StudyOverview.StudySourceType.CURATED, new Date());
7677
return new Study(studyOverview, rootEntity, entityIdMap);
7778
}
7879

0 commit comments

Comments
 (0)