Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/icatproject/core/entity/Datafile.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Datafile extends EntityBaseBean implements Serializable {
private String doi;

@Comment("Expressed in bytes")
private Long fileSize;
private Long fileSize = 0L;

@Comment("The logical location of the file - which may also be the physical location")
private String location;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/icatproject/core/entity/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class Dataset extends EntityBaseBean implements Serializable {
private List<Datafile> datafiles = new ArrayList<Datafile>();

@Comment("The cumulative total size of the data files within this dataset")
private Long fileSize;
private Long fileSize = 0L;

@Comment("The total number of datafiles within this dataset")
private Long fileCount;
private Long fileCount = 0L;

@Comment("An informal description of the data set")
private String description;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/icatproject/core/entity/Investigation.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class Investigation extends EntityBaseBean implements Serializable {
private List<Dataset> datasets = new ArrayList<>();

@Comment("The cumulative total size of the datasets within this investigation")
private Long fileSize;
private Long fileSize = 0L;

@Comment("The total number of datafiles within this investigation")
private Long fileCount;
private Long fileCount = 0L;

@Comment("The Digital Object Identifier associated with this investigation")
private String doi;
Expand Down
8 changes: 4 additions & 4 deletions src/main/scripts/create_triggers_mysql_5_0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ BEGIN

SELECT SUM(df.FILESIZE) INTO @FILE_SIZE FROM DATASET ds JOIN DATAFILE AS df ON df.DATASET_ID = ds.ID WHERE ds.ID = _id;
SELECT COUNT(df.ID) INTO @FILE_COUNT FROM DATASET ds JOIN DATAFILE AS df ON df.DATASET_ID = ds.ID WHERE ds.ID = _id;
UPDATE DATASET SET FILESIZE = @FILE_SIZE WHERE ID = _id;
UPDATE DATASET SET FILECOUNT = @FILE_COUNT WHERE ID = _id;
UPDATE DATASET SET FILESIZE = IFNULL(@FILE_SIZE, 0) WHERE ID = _id;
UPDATE DATASET SET FILECOUNT = IFNULL(@FILE_COUNT, 0) WHERE ID = _id;
END LOOP datasetLoop;
CLOSE cur;
END; //
Expand All @@ -143,8 +143,8 @@ BEGIN

SELECT SUM(ds.FILESIZE) INTO @FILE_SIZE FROM INVESTIGATION i JOIN DATASET AS ds ON ds.INVESTIGATION_ID = i.ID WHERE i.ID = _id;
SELECT SUM(ds.FILECOUNT) INTO @FILE_COUNT FROM INVESTIGATION i JOIN DATASET AS ds ON ds.INVESTIGATION_ID = i.ID WHERE i.ID = _id;
UPDATE INVESTIGATION SET FILESIZE = @FILE_SIZE WHERE ID = _id;
UPDATE INVESTIGATION SET FILECOUNT = @FILE_COUNT WHERE ID = _id;
UPDATE INVESTIGATION SET FILESIZE = IFNULL(@FILE_SIZE, 0) WHERE ID = _id;
UPDATE INVESTIGATION SET FILECOUNT = IFNULL(@FILE_COUNT, 0) WHERE ID = _id;
END LOOP investigationLoop;
CLOSE cur;
END; //
Expand Down
8 changes: 4 additions & 4 deletions src/main/scripts/create_triggers_oracle_5_0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ BEGIN
FOR CUR_DATASET in CUR LOOP
SELECT SUM(df.FILESIZE) INTO FILE_SIZE FROM DATASET ds JOIN DATAFILE df ON df.DATASET_ID = ds.ID WHERE ds.ID = CUR_DATASET.ID;
SELECT COUNT(df.ID) INTO FILE_COUNT FROM DATASET ds JOIN DATAFILE df ON df.DATASET_ID = ds.ID WHERE ds.ID = CUR_DATASET.ID;
UPDATE DATASET SET FILESIZE = FILE_SIZE WHERE ID = CUR_DATASET.ID;
UPDATE DATASET SET FILECOUNT = FILE_COUNT WHERE ID = CUR_DATASET.ID;
UPDATE DATASET SET FILESIZE = NVL(FILE_SIZE, 0) WHERE ID = CUR_DATASET.ID;
UPDATE DATASET SET FILECOUNT = NVL(FILE_COUNT, 0) WHERE ID = CUR_DATASET.ID;
END LOOP;
END;
/
Expand All @@ -151,8 +151,8 @@ BEGIN
FOR CUR_INVESTIGATION in CUR LOOP
SELECT SUM(ds.FILESIZE) INTO FILE_SIZE FROM INVESTIGATION i JOIN DATASET ds ON ds.INVESTIGATION_ID = i.ID WHERE i.ID = CUR_INVESTIGATION.ID;
SELECT SUM(ds.FILECOUNT) INTO FILE_COUNT FROM INVESTIGATION i JOIN DATASET ds ON ds.INVESTIGATION_ID = i.ID WHERE i.ID = CUR_INVESTIGATION.ID;
UPDATE INVESTIGATION SET FILESIZE = FILE_SIZE WHERE ID = CUR_INVESTIGATION.ID;
UPDATE INVESTIGATION SET FILECOUNT = FILE_COUNT WHERE ID = CUR_INVESTIGATION.ID;
UPDATE INVESTIGATION SET FILESIZE = NVL(FILE_SIZE, 0) WHERE ID = CUR_INVESTIGATION.ID;
UPDATE INVESTIGATION SET FILECOUNT = NVL(FILE_COUNT, 0) WHERE ID = CUR_INVESTIGATION.ID;
END LOOP;
END;
/
Expand Down