Example #1
0
        /// <summary>
        /// Change the URI identifier for this data object.
        /// </summary>
        /// <remarks>This change will update all triples where the data object identity
        /// is the subject or object. It will not change predicates.</remarks>
        /// <param name="newIdentity">The new URI identifier</param>
        /// <param name="enforceClassUniqueConstraint">Add an update precondition to ensure that the update will fail if the store already
        /// contains an RDF resource with the same rdf:type(s) as this data object.</param>
        public IDataObject UpdateIdentity(string newIdentity, bool enforceClassUniqueConstraint)
        {
            if (newIdentity == null)
            {
                throw new ArgumentNullException("newIdentity", "DataObject Identity must not be null");
            }
            if (String.IsNullOrWhiteSpace(newIdentity))
            {
                throw new ArgumentException("DataObject Identity must not be an empty string or whitespace.", "newIdentity");
            }
            if (newIdentity.Equals(Identity))
            {
                // No change
                return(this);
            }

            if (IsNew)
            {
                // Simple case - we only have to change the uncommitted triples locally.
                CheckLoaded();
                var ret = new DataObject(_store, newIdentity, true);
                ret.BindTriples(_triples.Select(t => ReplaceIdentity(t, newIdentity)), true, enforceClassUniqueConstraint);
                Delete();
                return(ret);
            }
            else
            {
                CheckLoaded();
                var ret = new DataObject(_store, newIdentity, true);
                ret.BindTriples(_triples.Union(_store.GetReferencingTriples(this)).Select(t => ReplaceIdentity(t, newIdentity)), true, enforceClassUniqueConstraint);
                Delete();
                return(ret);
            }
        }
        public override IDataObject GetDataObject(string identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            var resolvedIdentity = ResolveIdentity(identity);

            DataObject registeredDataObject = RegisterDataObject(new DataObject(this, resolvedIdentity));

            if (!registeredDataObject.IsLoaded)
            {
                var triples = GetFilteredResourceStatements(_storeName, resolvedIdentity)
                              .Union(AddTriples.GetMatches(resolvedIdentity));
                registeredDataObject.BindTriples(triples);
            }
            return(registeredDataObject);
        }
        public override IDataObject GetDataObject(string identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            var resolvedIdentity = ResolveIdentity(identity);

            DataObject registeredDataObject = RegisterDataObject(new DataObject(this, resolvedIdentity));

            if (!registeredDataObject.IsLoaded)
            {
                IEnumerable <Triple> triples =
                    _serverCore.GetResourceStatements(_storeName, resolvedIdentity).Union(
                        AddTriples.Where(p => p.Subject.Equals(resolvedIdentity)));
                registeredDataObject.BindTriples(triples);
            }
            return(registeredDataObject);
        }
        public override bool BindDataObject(DataObject dataObject)
        {
            var triples = GetFilteredResourceStatements(_storeName, dataObject.Identity);

            return(dataObject.BindTriples(triples));
        }
 public override bool BindDataObject(DataObject dataObject)
 {
     return dataObject.BindTriples(GetTriplesForDataObject(dataObject.Identity));
 }
        public override bool BindDataObject(DataObject dataObject)
        {
            IEnumerable <Triple> triples = _serverCore.GetResourceStatements(_storeName, dataObject.Identity);

            return(dataObject.BindTriples(triples));
        }
Example #7
0
        /// <summary>
        /// Change the URI identifier for this data object.
        /// </summary>
        /// <remarks>This change will update all triples where the data object identity
        /// is the subject or object. It will not change predicates.</remarks>
        /// <param name="newIdentity">The new URI identifier</param>
        /// <param name="enforceClassUniqueConstraint">Add an update precondition to ensure that the update will fail if the store already
        /// contains an RDF resource with the same rdf:type(s) as this data object.</param>
        public IDataObject UpdateIdentity(string newIdentity, bool enforceClassUniqueConstraint)
        {
            if (newIdentity == null) throw new ArgumentNullException("newIdentity", "DataObject Identity must not be null");
            if (String.IsNullOrWhiteSpace(newIdentity)) throw new ArgumentException("DataObject Identity must not be an empty string or whitespace.", "newIdentity");
            if (newIdentity.Equals(Identity))
            {
                // No change
                return this;
            }

            if (IsNew)
            {
                // Simple case - we only have to change the uncommitted triples locally.
                CheckLoaded();
                var ret = new DataObject(_store, newIdentity, true);
                ret.BindTriples(_triples.Select(t => ReplaceIdentity(t, newIdentity)), true, enforceClassUniqueConstraint);
                _store.ReplaceIdentity(Identity, newIdentity);
                Delete();
                return ret;
            }
            else
            {
                CheckLoaded();
                var ret = new DataObject(_store, newIdentity, true);
                ret.BindTriples(_triples.Union(_store.GetReferencingTriples(this)).Select(t => ReplaceIdentity(t, newIdentity)), true, enforceClassUniqueConstraint);
                _store.ReplaceIdentity(Identity, newIdentity);
                Delete();
                return ret;
            }
        }
 public override bool BindDataObject(DataObject dataObject)
 {
     var triples = GetFilteredResourceStatements(_storeName, dataObject.Identity);
     return dataObject.BindTriples(triples);
 }
 public override bool BindDataObject(DataObject dataObject)
 {
     IEnumerable<Triple> triples = _serverCore.GetResourceStatements(_storeName, dataObject.Identity);
     return dataObject.BindTriples(triples);
 }
 public override bool BindDataObject(DataObject dataObject)
 {
     return(dataObject.BindTriples(GetTriplesForDataObject(dataObject.Identity)));
 }