Exemplo n.º 1
0
        private MetadataProperty CreateMetadataPropertyFromList(string pidUri, List <SparqlResult> sparqlResults, string configIdentifier)
        {
            var metadataProperty = new MetadataProperty();

            metadataProperty.Properties.Add(Constants.EnterpriseCore.PidUri, pidUri);

            foreach (var res in sparqlResults)
            {
                var shaclProperty = GetDataFromNode(res, "shaclProperty").Value;
                var shaclValue    = GetDataFromNode(res, "shaclValue").Value;

                metadataProperty.Properties.AddOrUpdate(shaclProperty, shaclValue);

                switch (shaclProperty)
                {
                case Constants.TopBraid.EditWidget when shaclValue == Constants.TopBraid.NestedObjectEditor:
                    var nestedMetaDataType = GetDataFromNode(res, "nested").Value;
                    var nestedTypes        = GetEntityTypes(nestedMetaDataType);
                    metadataProperty.NestedMetadata = nestedTypes.SubClasses.Select(r => new DataModels.Metadata.Metadata(r.Id, r.Label, r.Description, GetMetadataForEntityTypeInConfig(r.Id, configIdentifier))).ToList();
                    break;

                case Constants.Shacl.Path when shaclValue == Constants.RDF.Type:
                    metadataProperty.Properties.AddOrUpdate(Constants.Shacl.Range, Constants.OWL.Class);
                    break;

                case Constants.Shacl.Group:
                    var group = new MetadataPropertyGroup();
                    group.Key   = GetDataFromNode(res, "group")?.Value;
                    group.Label = GetDataFromNode(res, "grouplabel")?.Value;
                    decimal.TryParse(GetDataFromNode(res, "groupOrder")?.Value, out decimal order);

                    group.Order           = order;
                    group.EditDescription = GetDataFromNode(res, "editGroupDescription")?.Value;
                    group.ViewDescription = GetDataFromNode(res, "viewGroupDescription")?.Value;
                    metadataProperty.Properties.AddOrUpdate(Constants.Shacl.Group, group);

                    break;
                }
            }
            ;

            return(metadataProperty);
        }
Exemplo n.º 2
0
        public static MetadataPropertyGroup GetMetadataPropertyGroup(this IDictionary <string, dynamic> metadataProperties)
        {
            MetadataPropertyGroup metadataGroup = null;

            if (metadataProperties != null && metadataProperties.TryGetValue(Shacl.Group, out var groupValue))
            {
                if (groupValue is JObject)
                {
                    var jsonObject = groupValue as JObject;
                    metadataGroup = jsonObject.ToObject <MetadataPropertyGroup>();
                }
                else if (groupValue is MetadataPropertyGroup)
                {
                    metadataGroup = groupValue;
                }
            }

            return(metadataGroup);
        }
 public MetadataPropertyBuilder WithGroup(MetadataPropertyGroup group)
 {
     _prop.Properties.AddOrUpdate(Graph.Metadata.Constants.Shacl.Group, group);
     return(this);
 }