AddItem() public method

Adds the given item to the collection, avoiding duplicate insertions
public AddItem ( Object item ) : RDFCollection
item Object
return RDFCollection
Example #1
0
        /// <summary>
        /// Gets a graph representation of this constraint
        /// </summary>
        internal override RDFGraph ToRDFGraph(RDFShape shape)
        {
            RDFGraph result = new RDFGraph();

            if (shape != null)
            {
                //Get collection from inValues
                RDFCollection inValues = new RDFCollection(this.ItemType)
                {
                    InternalReificationSubject = this
                };
                foreach (RDFPatternMember inValue in this.InValues.Values)
                {
                    if (this.ItemType == RDFModelEnums.RDFItemTypes.Literal)
                    {
                        inValues.AddItem((RDFLiteral)inValue);
                    }
                    else
                    {
                        inValues.AddItem((RDFResource)inValue);
                    }
                }
                result.AddCollection(inValues);

                //sh:in
                result.AddTriple(new RDFTriple(shape, RDFVocabulary.SHACL.IN, inValues.ReificationSubject));
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// Gets a graph representation of this constraint
        /// </summary>
        internal override RDFGraph ToRDFGraph(RDFShape shape)
        {
            RDFGraph result = new RDFGraph();

            if (shape != null)
            {
                //sh:closed
                result.AddTriple(new RDFTriple(shape, RDFVocabulary.SHACL.CLOSED, new RDFTypedLiteral(this.Closed.ToString(), RDFModelEnums.RDFDatatypes.XSD_BOOLEAN)));

                //Get collection from ignored properties
                RDFCollection ignoredProperties = new RDFCollection(RDFModelEnums.RDFItemTypes.Resource)
                {
                    InternalReificationSubject = this
                };
                foreach (RDFResource ignoredProperty in this.IgnoredProperties.Values)
                {
                    ignoredProperties.AddItem(ignoredProperty);
                }
                result.AddCollection(ignoredProperties);

                //sh:ignoredProperties
                result.AddTriple(new RDFTriple(shape, RDFVocabulary.SHACL.IGNORED_PROPERTIES, ignoredProperties.ReificationSubject));
            }
            return(result);
        }
        /// <summary>
        /// Gets a graph representation of this constraint
        /// </summary>
        internal override RDFGraph ToRDFGraph(RDFShape shape)
        {
            RDFGraph result = new RDFGraph();

            if (shape != null)
            {
                //Get collection from language tags
                RDFCollection languageTags = new RDFCollection(RDFModelEnums.RDFItemTypes.Literal)
                {
                    InternalReificationSubject = this
                };
                foreach (string languageTag in this.LanguageTags)
                {
                    languageTags.AddItem(new RDFPlainLiteral(languageTag));
                }
                result.AddCollection(languageTags);

                //sh:languageIn
                result.AddTriple(new RDFTriple(shape, RDFVocabulary.SHACL.LANGUAGE_IN, languageTags.ReificationSubject));
            }
            return(result);
        }
        /// <summary>
        /// Gets a graph representation of this constraint
        /// </summary>
        internal override RDFGraph ToRDFGraph(RDFShape shape)
        {
            RDFGraph result = new RDFGraph();

            if (shape != null)
            {
                //Get collection from xoneShapes
                RDFCollection xoneShapes = new RDFCollection(RDFModelEnums.RDFItemTypes.Resource)
                {
                    InternalReificationSubject = this
                };
                foreach (RDFResource xoneShape in this.XoneShapes.Values)
                {
                    xoneShapes.AddItem(xoneShape);
                }
                result.AddCollection(xoneShapes);

                //sh:xone
                result.AddTriple(new RDFTriple(shape, RDFVocabulary.SHACL.XONE, xoneShapes.ReificationSubject));
            }
            return(result);
        }