Skip to content

Commit

Permalink
Added code for switching to release version vs schema version
Browse files Browse the repository at this point in the history
  • Loading branch information
oblodgett committed Aug 20, 2019
1 parent 7cee817 commit c7bf9f2
Show file tree
Hide file tree
Showing 11 changed files with 481,222 additions and 99 deletions.
480,706 changes: 480,706 additions & 0 deletions output.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.alliancegenome</groupId>
<version>0.0.3</version>
<version>0.0.7</version>

<artifactId>agr_chipmunk</artifactId>
<name>AGR Java :: File Management System</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class DataFileController extends BaseController implements DataFileContro
@Inject DataFileService dataFileService;

@Override
public DataFile create(String schemaVersion, String dataType, String dataSubtype, DataFile entity) {
public DataFile create(String releaseVersion, String dataType, String dataSubtype, DataFile entity) {
if(entity != null) {
return dataFileService.create(schemaVersion, dataType, dataSubtype, entity);
return dataFileService.create(releaseVersion, dataType, dataSubtype, entity);
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,16 @@ public class SubmissionController extends BaseController implements SubmissionCo
private SubmissionService metaDataService;

@Override
public SubmissionResponce submitData(MultipartFormDataInput input) {
SubmissionResponce res = new SubmissionResponce();

Map<String, List<InputPart>> form = input.getFormDataMap();
boolean success = true;


for(String key: form.keySet()) {

InputPart inputPart = form.get(key).get(0);
Date d = new Date();
String outFileName = "tmp.data_" + d.getTime();
File outfile = new File(outFileName);
try {
InputStream is = inputPart.getBody(InputStream.class, null);

log.info("Saving file to local filesystem: " + outfile.getAbsolutePath());
FileUtils.copyInputStreamToFile(is, outfile);
log.info("Save file to local filesystem complete");

metaDataService.submitAndValidateDataFile(key, outfile, true);
res.getFileStatus().put(key, "success");
} catch (GenericException | IOException e) {
log.error(e.getMessage());
outfile.delete();
res.getFileStatus().put(key, e.getMessage());
//e.printStackTrace();
success = false;
}
}


if(success) {
res.setStatus("success");
} else {
res.setStatus("failed");
}
return res;

public APIResponce submitData(MultipartFormDataInput input) {
return processData(input, true);
}

@Override
public APIResponce validateData(MultipartFormDataInput input) {
return processData(input, false);
}

private APIResponce processData(MultipartFormDataInput input, boolean saveFile) {
SubmissionResponce res = new SubmissionResponce();

Map<String, List<InputPart>> form = input.getFormDataMap();
Expand All @@ -94,7 +61,7 @@ public APIResponce validateData(MultipartFormDataInput input) {
FileUtils.copyInputStreamToFile(is, outfile);
log.info("Save file to local filesystem complete");

boolean passed = metaDataService.submitAndValidateDataFile(key, outfile, false);
boolean passed = metaDataService.submitAndValidateDataFile(key, outfile, saveFile);

if(passed) {
res.getFileStatus().put(key, "success");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class DataFile extends BaseEntity {
@JsonView({View.DataFileView.class, View.SchemaVersionView.class, View.SnapShotView.class})
private Date uploadDate = new Date();

@ManyToOne
@JsonView({View.DataFileView.class})
private ReleaseVersion releaseVersion;

@ManyToOne
@JsonView({View.DataFileView.class})
private SchemaVersion schemaVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
Expand Down Expand Up @@ -34,4 +35,8 @@ public class ReleaseVersion extends BaseEntity {
@ManyToMany(fetch=FetchType.EAGER)
private List<SchemaVersion> schemaVersions = new ArrayList<>();

@OneToMany(mappedBy="releaseVersion", fetch=FetchType.EAGER)
@JsonView({View.ReleaseVersionView.class})
private Set<DataFile> dataFiles;

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ArrayList<DataFile> getDataFiles() {
ArrayList<DataFile> dataFiles = new ArrayList<DataFile>();
HashMap<MultiKey<String>, DataFile> currentFiles = new HashMap<>();

for(DataFile df: getSchemaVersion().getDataFiles()) {
for(DataFile df: releaseVersion.getDataFiles()) {
MultiKey<String> key = new MultiKey<String>(df.getDataType().getName(), df.getDataSubType().getName());
DataFile entry = currentFiles.get(key);
if(df.getUploadDate().before(snapShotDate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public interface DataFileControllerInterface {

@POST
@Secured
@Path("/{schemaVersion}/{dataType}/{dataSubtype}")
@Path("/{releaseVersion}/{dataType}/{dataSubtype}")
@JsonView(View.DataFileCreate.class)
public DataFile create(
@PathParam("schemaVersion") String schemaVersion,
@PathParam("releaseVersion") String releaseVersion,
@PathParam("dataType") String dataType,
@PathParam("dataSubtype") String dataSubtype,
DataFile entity
Expand Down
Loading

0 comments on commit c7bf9f2

Please sign in to comment.