public MetadataViewModel GetMetadataModel(string uuid)
{
SimpleMetadata metadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(uuid));
var model = new MetadataViewModel()
{
Uuid = metadata.Uuid,
Title = metadata.Title,
HierarchyLevel = metadata.HierarchyLevel,
ParentIdentifier = metadata.ParentIdentifier,
MetadataStandard = metadata.MetadataStandard,
Abstract = metadata.Abstract != null ? metadata.Abstract.Replace("...", "") : "",
Purpose = metadata.Purpose,
ContactMetadata = new Contact(metadata.ContactMetadata, "pointOfContact"),
ContactPublisher = new Contact(metadata.ContactPublisher, "publisher"),
ContactOwner = new Contact(metadata.ContactOwner, "owner"),
KeywordsTheme = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, SimpleKeyword.TYPE_THEME, null)),
KeywordsPlace = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, SimpleKeyword.TYPE_PLACE, null)),
KeywordsNationalInitiative = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_INITIATIVE)),
KeywordsNationalTheme = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_THEME)),
KeywordsConcept = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_CONCEPT)),
KeywordsInspire = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_GEMET_INSPIRE_V1)),
KeywordsServiceTaxonomy = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_SERVICES_TAXONOMY)),
KeywordsOther = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, null)),
KeywordsEnglish = CreateDictionaryOfEnglishKeywords(metadata.Keywords),
TopicCategory = metadata.TopicCategory,
SupplementalDescription = metadata.SupplementalDescription,
SpecificUsage = metadata.SpecificUsage,
ProductPageUrl = metadata.ProductPageUrl,
ProductSheetUrl = metadata.ProductSheetUrl,
ProductSpecificationUrl = metadata.ProductSpecificationUrl,
ApplicationSchema = metadata.ApplicationSchema,
LegendDescriptionUrl = metadata.LegendDescriptionUrl,
CoverageUrl = metadata.CoverageUrl,
Thumbnails = Thumbnail.CreateFromList(metadata.Thumbnails),
SpatialRepresentation = metadata.SpatialRepresentation,
DistributionFormatName = metadata.DistributionFormat != null ? metadata.DistributionFormat.Name : null,
DistributionFormatVersion = metadata.DistributionFormat != null ? metadata.DistributionFormat.Version : null,
DistributionFormats = metadata.DistributionFormats != null ? metadata.DistributionFormats : new List<SimpleDistributionFormat> { new SimpleDistributionFormat() },
DistributionUrl = metadata.DistributionDetails != null ? metadata.DistributionDetails.URL : null,
DistributionProtocol = metadata.DistributionDetails != null ? metadata.DistributionDetails.Protocol : null,
DistributionName = metadata.DistributionDetails != null ? metadata.DistributionDetails.Name : null,
UnitsOfDistribution = metadata.DistributionDetails != null ? metadata.DistributionDetails.UnitsOfDistribution : null,
ReferenceSystemCoordinateSystem = metadata.ReferenceSystem != null ? metadata.ReferenceSystem.CoordinateSystem : null,
ReferenceSystemNamespace = metadata.ReferenceSystem != null ? metadata.ReferenceSystem.Namespace : null,
ReferenceSystems = metadata.ReferenceSystems != null && metadata.ReferenceSystems.Count == 0 ? null : metadata.ReferenceSystems,
//QualitySpecificationDate = (metadata.QualitySpecification != null && !string.IsNullOrWhiteSpace(metadata.QualitySpecification.Date)) ? DateTime.Parse(metadata.QualitySpecification.Date) : (DateTime?)null,
//QualitySpecificationDateType = metadata.QualitySpecification != null ? metadata.QualitySpecification.DateType : null,
//QualitySpecificationExplanation = metadata.QualitySpecification != null ? metadata.QualitySpecification.Explanation : null,
//QualitySpecificationResult = metadata.QualitySpecification != null ? metadata.QualitySpecification.Result : false,
//QualitySpecificationTitle = metadata.QualitySpecification != null ? metadata.QualitySpecification.Title : null,
ProcessHistory = metadata.ProcessHistory,
MaintenanceFrequency = metadata.MaintenanceFrequency,
ResolutionScale = metadata.ResolutionScale,
UseLimitations = metadata.Constraints != null ? metadata.Constraints.UseLimitations : null,
EnglishUseLimitations = metadata.Constraints != null ? metadata.Constraints.EnglishUseLimitations : null,
UseConstraints = metadata.Constraints != null ? metadata.Constraints.UseConstraints : null,
AccessConstraints = metadata.Constraints != null ? metadata.Constraints.AccessConstraints : null,
SecurityConstraints = metadata.Constraints != null ? metadata.Constraints.SecurityConstraints : null,
SecurityConstraintsNote = metadata.Constraints != null ? metadata.Constraints.SecurityConstraintsNote : null,
OtherConstraints = metadata.Constraints != null ? metadata.Constraints.OtherConstraints : null,
EnglishOtherConstraints = metadata.Constraints != null ? metadata.Constraints.EnglishOtherConstraints : null,
OtherConstraintsLink = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsLink : null,
OtherConstraintsLinkText = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsLinkText : null,
OtherConstraintsAccess = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsAccess : null,
DateCreated = metadata.DateCreated,
DatePublished = metadata.DatePublished,
DateUpdated = metadata.DateUpdated,
DateMetadataUpdated = metadata.DateMetadataUpdated,
DateMetadataValidFrom = string.IsNullOrEmpty(metadata.ValidTimePeriod.ValidFrom) ? (DateTime?)null : DateTime.Parse(metadata.ValidTimePeriod.ValidFrom),
DateMetadataValidTo = string.IsNullOrEmpty(metadata.ValidTimePeriod.ValidTo) ? (DateTime?)null : DateTime.Parse(metadata.ValidTimePeriod.ValidTo),
Status = metadata.Status,
OrderingInstructions = (metadata.AccessProperties != null && !string.IsNullOrEmpty(metadata.AccessProperties.OrderingInstructions)) ? metadata.AccessProperties.OrderingInstructions : "",
BoundingBoxEast = metadata.BoundingBox != null ? metadata.BoundingBox.EastBoundLongitude : null,
BoundingBoxWest = metadata.BoundingBox != null ? metadata.BoundingBox.WestBoundLongitude : null,
BoundingBoxNorth = metadata.BoundingBox != null ? metadata.BoundingBox.NorthBoundLatitude : null,
BoundingBoxSouth = metadata.BoundingBox != null ? metadata.BoundingBox.SouthBoundLatitude : null,
EnglishTitle = metadata.EnglishTitle,
EnglishAbstract = metadata.EnglishAbstract,
EnglishPurpose = metadata.EnglishPurpose,
EnglishSupplementalDescription = metadata.EnglishSupplementalDescription,
EnglishSpecificUsage = metadata.EnglishSpecificUsage,
EnglishProcessHistory = metadata.EnglishProcessHistory,
EnglishContactMetadataOrganization = metadata.ContactMetadata != null ? metadata.ContactMetadata.OrganizationEnglish : null,
EnglishContactPublisherOrganization = metadata.ContactPublisher != null ? metadata.ContactPublisher.OrganizationEnglish : null,
EnglishContactOwnerOrganization = metadata.ContactOwner != null ? metadata.ContactOwner.OrganizationEnglish : null,
};
if (metadata.BoundingBox != null)
{
model.BoundingBoxEast = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.EastBoundLongitude);
model.BoundingBoxWest = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.WestBoundLongitude);
model.BoundingBoxNorth = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.NorthBoundLatitude);
model.BoundingBoxSouth = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.SouthBoundLatitude);
}
if (metadata.ProductSpecificationOther != null)
{
model.ProductSpecificationOther = new SimpleOnlineResource
{
Name = metadata.ProductSpecificationOther.Name,
URL = metadata.ProductSpecificationOther.URL
};
}
model.FixThumbnailUrls();
model.OperatesOn = metadata.OperatesOn !=null ? metadata.OperatesOn : new List<string>();
if (metadata.ResourceReference != null)
{
model.ResourceReferenceCode = metadata.ResourceReference.Code != null ? metadata.ResourceReference.Code : null;
model.ResourceReferenceCodespace = metadata.ResourceReference.Codespace != null ? metadata.ResourceReference.Codespace : null;
}
getQualitySpecifications(model, metadata);
return model;
}