private DatasetNominationStorageItem CreateNominationStorageItemForLicensePropertyTests(NominationLicenseType licenseType)
        {
            var licenseId      = new Guid();
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("OtherLicenseContentHtml");
            var contentHtml    = Convert.ToBase64String(plainTextBytes);

            var storageItem = new DatasetNominationStorageItem()
            {
                NominationLicenseType         = licenseType,
                LicenseId                     = licenseId,
                OtherLicenseContentHtml       = contentHtml,
                OtherLicenseFileName          = "OtherLicenseFileName",
                OtherLicenseAdditionalInfoUrl = "OtherLicenseAdditionalInfoUrl",
                OtherLicenseName              = "OtherLicenseName"
            };

            return(storageItem);
        }
Beispiel #2
0
 public static DatasetNomination ToDatasetNomination(this DatasetNominationStorageItem source, Action <DatasetNomination> update = null)
 {
     return(ModelMapper <DatasetNominationStorageItemMapper> .Mapper.Map(source).WithUpdate(update));
 }
Beispiel #3
0
        private async Task CreateNominationDocFromEditDoc(DatasetEditStorageItem dataset, CancellationToken token)
        {
            // Disallow changes to the edited container
            await SasTokens.DisableSasTokenForUpdatingDatasetContainer(dataset.ContentEditAccount, dataset.ContentEditContainer);

            // Update the status of edit document.
            dataset.EditStatus = DatasetEditStatus.Importing;
            await Client.ReplaceDocumentAsync(
                UserDataDocumentUriById(dataset.Id.ToString()),
                dataset,
                new RequestOptions
            {
                PartitionKey = new PartitionKey(WellKnownIds.DatasetEditDatasetId.ToString())
            },
                token);

            // Create nomination document
            var nomination = new DatasetNominationStorageItem
            {
                Id                            = dataset.Id,
                DatasetId                     = WellKnownIds.DatasetNominationDatasetId,
                Name                          = dataset.Name,
                Description                   = dataset.Description,
                Domain                        = dataset.Domain,
                DomainId                      = dataset.DomainId,
                SourceUri                     = dataset.SourceUri,
                ProjectUri                    = dataset.ProjectUri,
                Version                       = dataset.Version,
                Published                     = dataset.Published,
                Created                       = dataset.Created,
                Modified                      = dataset.Modified,
                License                       = dataset.License,
                LicenseId                     = dataset.LicenseId,
                Tags                          = (dataset.Tags ?? Enumerable.Empty <string>()).ToList(),
                ContactName                   = dataset.ContactName,
                ContactInfo                   = dataset.ContactInfo,
                CreatedByUserId               = dataset.CreatedByUserId,
                CreatedByUserName             = dataset.CreatedByUserName,
                CreatedByUserEmail            = dataset.CreatedByUserEmail,
                ModifiedByUserName            = dataset.ModifiedByUserName,
                ModifiedByUserEmail           = dataset.ModifiedByUserEmail,
                IsDownloadAllowed             = dataset.IsDownloadAllowed,
                NominationStatus              = NominationStatus.Importing,
                NominationLicenseType         = dataset.NominationLicenseType,
                DigitalObjectIdentifier       = dataset.DigitalObjectIdentifier,
                OtherLicenseContentHtml       = dataset.OtherLicenseContentHtml,
                OtherLicenseFileContent       = dataset.OtherLicenseFileContent,
                OtherLicenseFileContentType   = dataset.OtherLicenseFileContentType,
                OtherLicenseAdditionalInfoUrl = dataset.OtherLicenseAdditionalInfoUrl,
                OtherLicenseName              = dataset.OtherLicenseName,
                OtherLicenseFileName          = dataset.OtherLicenseFileName
            };
            await Client.UpsertDocumentAsync(
                UserDataDocumentCollectionUri,
                nomination,
                new RequestOptions
            {
                PartitionKey = new PartitionKey(WellKnownIds.DatasetNominationDatasetId.ToString())
            },
                false,
                token);

            // Point nomination document to updated container
            var datasetRecordLink = new Attachment
            {
                Id          = "Content",
                ContentType = "x-azure-blockstorage",
                MediaLink   = SasTokens.GetContainerMediaLink(
                    dataset.ContentEditAccount,
                    dataset.ContentEditContainer)
            };

            datasetRecordLink.SetPropertyValue("storageType", "blob");
            datasetRecordLink.SetPropertyValue("container", dataset.ContentEditContainer);
            datasetRecordLink.SetPropertyValue("account", dataset.ContentEditAccount);
            await Client.UpsertAttachmentAsync(
                UserDataDocumentUriById(dataset.Id.ToString()),
                datasetRecordLink,
                new RequestOptions
            {
                PartitionKey = new PartitionKey(WellKnownIds.DatasetNominationDatasetId.ToString())
            },
                token);
        }