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
21 changes: 11 additions & 10 deletions Components/IO/BExIS.Io/IoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static string GetDynamicStoreFilePath(long datasetId, long datasetVersion
return Path.Combine(storePath, fileName + extention);
}

public static string GetFileName(FileType type, long datasetId, int versionNr, long datastructureId, string title = "")
public static string GetFileName(FileType type, long datasetId, int versionNr, long datastructureId, string title = "", double tagNr = 0, bool useTags = false, bool useMinor = false)
{
string appName = GeneralSettings.ApplicationName;
if (string.IsNullOrEmpty(appName)) appName = "BEXIS2";
Expand All @@ -45,41 +45,42 @@ public static string GetFileName(FileType type, long datasetId, int versionNr, l

string downloadTitle = FileNameUtility.SanitizeFileName(title,'-');


string versionOrTagLabel = useTags? "t"+tagNr : "v" + versionNr;

// tag vs version?
// if tag active but not tag is set, t0

switch (type)
{
case FileType.Metadata:
// filename should contain: application name, dataset ID, and version ID
downloadName = string.Format("{0}_{1}_v{2}_metadata", appName, datasetId, versionNr);
downloadName = string.Format("{0}_{1}_{2}_metadata", appName, datasetId, versionOrTagLabel);
break;
case FileType.MetadataExport:
// filename should contain: application name, dataset ID, and version ID
downloadName = string.Format("{0}_{1}_v{2}_metadata_{3}", appName, datasetId, versionNr, title);
downloadName = string.Format("{0}_{1}_{2}_metadata_{3}", appName, datasetId, versionOrTagLabel, title);
break;
case FileType.DataStructure:
downloadName = string.Format("{0}_{1}_data_structure_{2}", appName, datasetId, datastructureId);
break;
case FileType.PrimaryData:
downloadName = string.Format("{0}_{1}_v{2}_data", appName, datasetId, versionNr);
downloadName = string.Format("{0}_{1}_{2}_data", appName, datasetId, versionOrTagLabel);

break;
case FileType.PrimaryDataFiles:
downloadName = string.Format("{0}_{1}_v{2}_data_{3}", appName, datasetId, versionNr, title);
downloadName = string.Format("{0}_{1}_v{2}_data_{3}", appName, datasetId, versionOrTagLabel, title);
break;
case FileType.Attachments:
downloadName = string.Format("{0}_{1}_v{2}_attachment_{3}", appName, datasetId, versionNr, title);
downloadName = string.Format("{0}_{1}_{2}_attachment_{3}", appName, datasetId, versionOrTagLabel, title);
break;
case FileType.Bundle:
downloadName = string.Format("{0}_{1}_v{2}_{3}_{4}", appName, datasetId, versionNr, downloadTitle, downloadDate);
downloadName = string.Format("{0}_{1}_{2}_{3}_{4}", appName, datasetId, versionOrTagLabel, downloadTitle, downloadDate);
break;
case FileType.Manifest:
downloadName = string.Format("{0}_{1}_v{2}_general_metadata", appName, datasetId, versionNr);
downloadName = string.Format("{0}_{1}_{2}_general_metadata", appName, datasetId, versionOrTagLabel);
break;
default:
downloadName = string.Format("{0}_{1}_v{2}_{3}", appName, datasetId, versionNr, title);
downloadName = string.Format("{0}_{1}_{2}_{3}", appName, datasetId, versionOrTagLabel, title);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,11 @@ public ActionResult DownloadZip(long id, string format, long version = -1,bool w
{
if (this.IsAccessible("DIM", "Export", "GenerateZip"))
{
var actionresult = this.Run("DIM", "Export", "GenerateZip", new RouteValueDictionary() { { "id", id }, { "versionid", version }, { "format", format }, { "withFilter", withFilter }, { "withUnits", withUnits } });
var moduleSettings = ModuleManager.GetModuleSettings("Ddm");
bool useTags = (Boolean)moduleSettings.GetValueByKey("use_tags");
bool useMinorTag = (Boolean)moduleSettings.GetValueByKey("use_minor");

var actionresult = this.Run("DIM", "Export", "GenerateZip", new RouteValueDictionary() { { "id", id }, { "versionid", version }, { "format", format }, { "withFilter", withFilter }, { "withUnits", withUnits },{"useTags", useTags}, { "useMinor", useMinorTag} });

return actionresult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public ActionResult SimpleDataStructure(long id)
}
}

public ActionResult GenerateZip(long id, long versionid, string format,bool withFilter = false, bool withUnits = false)
public ActionResult GenerateZip(long id, long versionid, string format, bool withFilter = false, bool withUnits = false, bool useTags = false, bool useMinor = false)
{
XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
DatasetManager dm = new DatasetManager();
Expand All @@ -213,7 +213,12 @@ public ActionResult GenerateZip(long id, long versionid, string format,bool with
long dataStructureId = 0;
int datasetVersionNumber = dm.GetDatasetVersionNr(datasetVersionId);
DatasetVersion datasetVersion = datasetManager.GetDatasetVersion(datasetVersionId);
string title = "";

double tagNr = datasetVersion.Tag!=null?datasetVersion.Tag.Nr:0;


string title = "";


#region Metadata

Expand Down Expand Up @@ -298,7 +303,7 @@ public ActionResult GenerateZip(long id, long versionid, string format,bool with

#region zip file

string zipName = IOHelper.GetFileName(FileType.Bundle, id, datasetVersionNumber, dataStructureId, title); //publishingManager.GetZipFileName(id, datasetVersionNumber);
string zipName = IOHelper.GetFileName(FileType.Bundle, id, datasetVersionNumber, dataStructureId, title,tagNr,useTags,useMinor); //publishingManager.GetZipFileName(id, datasetVersionNumber);
// add suffix if filter is in use
if (isFilterInUse & withFilter) zipName += "_filtered";

Expand Down Expand Up @@ -326,15 +331,15 @@ public ActionResult GenerateZip(long id, long versionid, string format,bool with
{
if (cd.Name.Equals("metadata"))
{
name = IOHelper.GetFileName(FileType.Metadata, id, datasetVersionNumber, dataStructureId) + ext;
name = IOHelper.GetFileName(FileType.Metadata, id, datasetVersionNumber, dataStructureId,"", tagNr, useTags, useMinor) + ext;
}
else if (cd.Name.Equals("datastructure"))
{
name = IOHelper.GetFileName(FileType.DataStructure, id, datasetVersionNumber, dataStructureId) + ext;
name = IOHelper.GetFileName(FileType.DataStructure, id, datasetVersionNumber, dataStructureId,"", tagNr, useTags, useMinor) + ext;
}
else if (cd.Name.Contains("generated"))
{
name = IOHelper.GetFileName(FileType.PrimaryData, id, datasetVersionNumber, dataStructureId) + ext;
name = IOHelper.GetFileName(FileType.PrimaryData, id, datasetVersionNumber, dataStructureId, "", tagNr, useTags, useMinor) + ext;
}
else // all other files from unstructured and attachments
// get filename from path
Expand All @@ -356,7 +361,7 @@ public ActionResult GenerateZip(long id, long versionid, string format,bool with
{
string path = Path.Combine(AppConfiguration.DataPath, filteredFilePath);
string ext = Path.GetExtension(filteredFilePath).ToLower();
string name = IOHelper.GetFileName(FileType.PrimaryData, id, datasetVersionNumber, dataStructureId)+"_filtered"+ ext;
string name = IOHelper.GetFileName(FileType.PrimaryData, id, datasetVersionNumber, dataStructureId, "", tagNr, useTags, useMinor)+"_filtered"+ ext;

archive.AddFileToArchive(filteredFilePath, name);
}
Expand Down Expand Up @@ -389,7 +394,7 @@ public ActionResult GenerateZip(long id, long versionid, string format,bool with

if (manifest != null)
{
string manifestFileName = IOHelper.GetFileName(FileType.Manifest, id, datasetVersionNumber, dataStructureId);
string manifestFileName = IOHelper.GetFileName(FileType.Manifest, id, datasetVersionNumber, dataStructureId,"", tagNr, useTags, useMinor);
string manifestPath = OutputDatasetManager.GetDynamicDatasetStorePath(id,
datasetVersionNumber, "general_metadata", ".json");
string fullFilePath = Path.Combine(AppConfiguration.DataPath, manifestPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ul class="list-none">
{#each value as elem}
{#if elem != undefined}
<li><a class="a" href="/ddm/show?id={elem}">{elem}</a></li>
<li><a class="a" href="/ddm/data/show?id={elem}">{elem}</a></li>
{/if}
{/each}
</ul>
Expand Down
Loading