Skip to content

Commit

Permalink
Merge pull request #1055 from griidc/release/6.10.0
Browse files Browse the repository at this point in the history
Release/6.10.0
  • Loading branch information
praneethpr authored Nov 23, 2021
2 parents 20ff4f5 + 85ceecf commit 15b27a6
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 55 deletions.
2 changes: 2 additions & 0 deletions assets/static/js/dataset-submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ $(function() {
submitHandler: function(form) {
formHash = $("#regForm").serialize();
$("#regForm").prop("unsavedChanges", false);
$("#submitButton").button("disable");
pelagosUI.loadingSpinner.showSpinner();
form.submit();
},
});
Expand Down
4 changes: 3 additions & 1 deletion assets/static/js/datasetReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ $(document).ready(function(){
},
ignore: ".ignore,.prototype",
submitHandler: function (form) {
$("#acceptDatasetBtn, #endReviewBtn, #requestRevisionsBtn").button("disable");
pelagosUI.loadingSpinner.showSpinner();
form.submit();
}
});

// load qTip descriptions
$("img.info").not("#contact-prototype img.info").each(function() {
$(this).qtip({
Expand Down
39 changes: 11 additions & 28 deletions src/Controller/UI/DatasetReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ private function createEntity(Entity $entity)
*/
public function postAction(Request $request, int $id = null, MessageBusInterface $messageBus)
{
$datasetSubmission = $this->entityHandler->get(DatasetSubmission::class, $id);
$entityManager = $this->getDoctrine()->getManager();
$datasetSubmission = $entityManager->getRepository(DatasetSubmission::class)->find($id);

if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirect(
Expand Down Expand Up @@ -475,35 +476,9 @@ public function postAction(Request $request, int $id = null, MessageBusInterface
if ($fileset instanceof Fileset) {
foreach ($fileset->getNewFiles() as $file) {
$file->setStatus(File::FILE_IN_QUEUE);
$this->entityHandler->update($file);
}
}

$this->entityHandler->update($datasetSubmission->getDatasetSubmissionReview());
$this->entityHandler->update($datasetSubmission);

foreach ($datasetSubmission->getDistributionPoints() as $distributionPoint) {
$this->entityHandler->update($distributionPoint);
}

foreach ($datasetSubmission->getDatasetContacts() as $datasetContact) {
$this->entityHandler->update($datasetContact);
}

foreach ($datasetSubmission->getMetadataContacts() as $metadataContact) {
$this->entityHandler->update($metadataContact);
}

foreach ($datasetSubmission->getDatasetLinks() as $datasetLink) {
$this->entityHandler->update($datasetLink);
}

// update MDAPP logs after action is executed.
$this->entityEventDispatcher->dispatch(
$datasetSubmission,
$eventName
);

$reviewedBy = $datasetSubmission->getDatasetSubmissionReview()->getReviewEndedBy()->getFirstName();

//when request revisions is clicked, do not display the changes made in review for the dataset-submission
Expand Down Expand Up @@ -532,10 +507,18 @@ public function postAction(Request $request, int $id = null, MessageBusInterface
}
$datasetSubmission = $datasetSubmission->getDataset()->getDatasetSubmission();
$datasetSubmission->setFileset($newFileset);
$this->entityHandler->update($datasetSubmission);
$entityManager->persist($newFileset);
}
}

$entityManager->flush();

// update MDAPP logs after action is executed.
$this->entityEventDispatcher->dispatch(
$datasetSubmission,
$eventName
);

$datasetSubmissionFilerMessage = new DatasetSubmissionFiler($datasetSubmission->getId());
$messageBus->dispatch($datasetSubmissionFilerMessage);

Expand Down
19 changes: 3 additions & 16 deletions src/Controller/UI/DatasetSubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ public function defaultAction(Request $request, EntityManagerInterface $entityMa
*/
public function postAction(Request $request, int $id = null, MessageBusInterface $messageBus)
{
$datasetSubmission = $this->entityHandler->get(DatasetSubmission::class, $id);
$entityManager = $this->getDoctrine()->getManager();
$datasetSubmission = $entityManager->getRepository(DatasetSubmission::class)->find($id);

if (!$this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirect(
Expand Down Expand Up @@ -248,24 +249,10 @@ public function postAction(Request $request, int $id = null, MessageBusInterface
if ($fileset instanceof Fileset) {
foreach ($fileset->getNewFiles() as $file) {
$file->setStatus(File::FILE_IN_QUEUE);
$this->entityHandler->update($file);
}
}

$this->entityHandler->update($datasetSubmission);

foreach ($datasetSubmission->getDistributionPoints() as $distributionPoint) {
$this->entityHandler->update($distributionPoint);
}
foreach ($datasetSubmission->getDatasetContacts() as $datasetContact) {
$this->entityHandler->update($datasetContact);
}
foreach ($datasetSubmission->getMetadataContacts() as $metadataContact) {
$this->entityHandler->update($metadataContact);
}
foreach ($datasetSubmission->getDatasetLinks() as $datasetLink) {
$this->entityHandler->update($datasetLink);
}
$entityManager->flush();

$this->entityEventDispatcher->dispatch(
$datasetSubmission,
Expand Down
12 changes: 12 additions & 0 deletions src/Entity/Fileset.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,16 @@ public function getNumberOfFiles(): int
{
return count($this->getProcessedAndNewFiles());
}

/**
* Returns the number of errored files in the fileset.
*
* @return integer
*/
public function getNumberOfErroredFiles(): int
{
return count($this->files->filter(function (File $file) {
return $file->getStatus() === File::FILE_ERROR;
}));
}
}
15 changes: 10 additions & 5 deletions src/MessageHandler/ProcessFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ public function __invoke(ProcessFile $processFile)
);

$filePath = $file->getPhysicalFilePath();
$fileStream = fopen($filePath, 'r');
try {
@$fileStream = fopen($filePath, 'r');

if ($fileStream === false) {
$file->setDescription("Unreadable Queued File:" . error_get_last()['message']);
$file->setStatus(File::FILE_ERROR);
$this->entityManager->flush();
return;
} else {
$fileHash = StreamInfo::calculateHash(array('fileStream' => $fileStream));
$file->setFileSha256Hash($fileHash);
} catch (\Exception $e) {
$this->logger->warning(sprintf('Unable to hash file. Message: %s', $e->getMessage()));
}

try {
Expand All @@ -123,11 +127,12 @@ public function __invoke(ProcessFile $processFile)
$file->setPhysicalFilePath($newFileDestination);
} catch (\Exception $exception) {
$this->logger->error(sprintf('Unable to add file to datastore. Message: "%s"', $exception->getMessage()), $loggingContext);
$file->setDescription("Error writing to store:" . $exception->getMessage());
$file->setStatus(File::FILE_ERROR);
$this->entityManager->flush();
return;
}

try {
unlink($filePath);
rmdir(dirname($filePath));
Expand Down
5 changes: 0 additions & 5 deletions templates/DatasetMonitoring/projects.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
{% if instName | default %}
<span class="header-inst-name">({{instName}})</span>
{% endif %}
{% if not pdf | default %}
<span class="awesome-icon awesome-icon-pdf" data-url="/html2pdf?url={{ url(app.request.get('_route'), {'id': id, 'renderer': 'html2pdf'}) }}&format=Letter&orientation=landscape&margin=1cm&download=true&filename={{pdfFilename}}">
<i class="fas fa-file-pdf" style="color: red"></i>
</span>
{% endif %}
</div>
{% for ResearchGroup in researchGroups %}
<div class="project" project="{{ResearchGroup.id}}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% if datasetSubmission.fileset is defined and datasetSubmission.fileset is not null %}
Number of Files: {{ datasetSubmission.fileset.numberOfFiles }} <br>
Total File Size: {{ datasetSubmission.fileset.fileSize|formatBytes }}<br>
Files with error: {{ datasetSubmission.fileset.numberOfErroredFiles }}<br>
{% else %}
N/A<br>
{% endif %}
Expand Down Expand Up @@ -44,6 +45,7 @@
{% if datasetSubmission.fileset is defined and datasetSubmission.fileset is not null %}
Number of Files: {{ datasetSubmission.fileset.numberOfFiles }}
Total File Size: {{ datasetSubmission.fileset.fileSize|formatBytes }}
Files with error: {{ datasetSubmission.fileset.numberOfErroredFiles }}
{% else %}
N/A
{% endif %}
Expand Down

0 comments on commit 15b27a6

Please sign in to comment.