Exemplo n.º 1
0
        /// <summary>
        /// serializes resource metadata
        /// </summary>
        /// <param name="writer">xml writer</param>
        private void SerializeResourceMetaData(XmlWriter writer)
        {
            foreach (PropertyInformation info in state.ScalarProperties.Where(info => info.PropertyValue != ""))
            {
                if (info.PropertyName.ToUpperInvariant() == "ID" ||
                    info.PropertyName.ToUpperInvariant() == "TITLE" ||
                    info.PropertyName.ToUpperInvariant() == "IMAGE")
                {
                    continue;
                }
                writer.WriteStartElement(TermsMgr.GetInstance().GetStandardTerms("field:" + info.PropertyName.ToString()));
                writer.WriteStartAttribute("rdf", "datatype", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                info.PropertyType = GetPropertyType(info.PropertyType);
                writer.WriteValue(info.PropertyType);
                writer.WriteEndAttribute();
                writer.WriteValue(info.PropertyValue);
                writer.WriteEndElement();
            }

            PropertyInformation pinfo = state.ScalarProperties.Where(p => p.PropertyName.ToLower() == "title").FirstOrDefault();

            if (pinfo != null)
            {
                writer.WriteStartElement(TermsMgr.GetInstance().GetStandardTerms("field:Title"));
                writer.WriteValue(pinfo.PropertyValue);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();//rdf desc
        }
Exemplo n.º 2
0
        /// <summary>
        /// serializes the aggregations
        /// </summary>
        /// <param name="writer">xml writer</param>
        private void SerializeAggregations(XmlWriter writer)
        {
            //<ore:aggregates rdf:resource=resourceId />
            int i = 0;

            foreach (AbstractAggregatedResource <URI> aggregateResource in state.AggreagtedResources)
            {
                writer.WriteStartElement("ore:aggregates");
                writer.WriteStartAttribute("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(aggregateResource.ResourceUri.ToString());
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }

            for (i = 0; i < state.RelationUris.Count(); i++)
            {
                if (IsSpecialRelation(state.RelationUris[i]))
                {
                    continue;
                }
                writer.WriteStartElement("ore:aggregates");
                writer.WriteStartAttribute("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(state.ObjectResourceIds[i].ToString());
                writer.WriteEndAttribute();

                writer.WriteEndElement();
            }
            writer.WriteStartElement("rdf:type", "");
            writer.WriteStartAttribute("rdf:resource", "");
            writer.WriteValue(TermsMgr.GetInstance().GetStandardTerms("type:" + state.ResourceType.ToString()));
            writer.WriteEndAttribute();
            writer.WriteEndElement();
        }
Exemplo n.º 3
0
        /// <summary>
        /// serialize aggregated by resource
        /// </summary>
        /// <param name="deployedAt">deployed at string</param>
        /// <param name="writer">xml writer</param>
        private void SerializeAggregateByResource(string deployedAt, XmlWriter writer)
        {
            int j = 0;
            int i = 0;

            foreach (AbstractAggregatedResource <URI> aggregateResource in state.AggreagtedResources)
            {
                writer.WriteStartElement("rdf", "Description", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteStartAttribute("rdf", "about", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(aggregateResource.ResourceUri.ToString());
                writer.WriteEndAttribute();

                writer.WriteStartElement("rdf:type", "");
                writer.WriteStartAttribute("rdf:resource", "");
                writer.WriteValue(TermsMgr.GetInstance().GetStandardTerms("type:" + state.AggregateTypes[j++].ToString()));
                writer.WriteEndAttribute();
                writer.WriteEndElement(); //rdf:type

                writer.WriteStartElement("ore:isAggregatedBy");
                writer.WriteStartAttribute("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(deployedAt + aggregateResource.ResourceUri.ToString() + "#aggregation");
                writer.WriteEndAttribute();
                writer.WriteEndElement(); //aggregated by

                writer.WriteEndElement(); //rdf description
            }
            for (i = 0; i < state.RelationUris.Count(); i++)
            {
                if (IsSpecialRelation(state.RelationUris[i]))
                {
                    continue;
                }
                writer.WriteStartElement("rdf", "Description", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteStartAttribute("rdf", "about", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(state.ObjectResourceIds[i].ToString());
                writer.WriteEndAttribute();

                writer.WriteStartElement("rdf:type", "");
                writer.WriteStartAttribute("rdf:resource", "");
                writer.WriteValue(TermsMgr.GetInstance().GetStandardTerms(state.RelationUris[i]));
                writer.WriteEndAttribute();
                writer.WriteEndElement(); //rdf:type

                writer.WriteStartElement("ore:isAggregatedBy");
                writer.WriteStartAttribute("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
                writer.WriteValue(deployedAt + state.ObjectResourceIds[i].ToString() + "#aggregation");
                writer.WriteEndAttribute();
                writer.WriteEndElement(); //aggregated by

                writer.WriteEndElement(); //rdf description
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// serialize resource relations
 /// </summary>
 /// <param name="writer">xml writer</param>
 private void SerializeResourceRelations(XmlWriter writer)
 {
     //TODO :what to do for Custom Predicates
     for (int i = 0; i < state.RelationUris.Count(); i++)
     {
         if (IsSpecialRelation(state.RelationUris[i]))
         {
             writer.WriteStartElement(TermsMgr.GetInstance().GetStandardTerms(state.RelationUris[i]));
             writer.WriteStartAttribute("rdf", "resource", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
             writer.WriteValue(state.ObjectResourceIds[i].ToString());
             writer.WriteEndAttribute();
             writer.WriteStartAttribute("rdf", "type", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
             writer.WriteValue(TermsMgr.GetInstance().GetStandardTerms("type:" + state.ObjectTypes[i].ToString()));
             writer.WriteEndAttribute();
             writer.WriteEndElement();
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// serializes tag and categories
        /// </summary>
        /// <param name="writer">The xml writer.</param>
        private void SerializeTagRelations(XmlWriter writer)
        {
            string stdTerm = TermsMgr.GetInstance().GetStandardTerms("Tag");

            for (int i = 0; i < state.TagNames.Count(); i++)
            {
                writer.WriteStartElement(stdTerm);
                writer.WriteStartAttribute(TermsMgr.GetInstance().GetStandardTerms("field:Title"));
                writer.WriteValue(state.TagNames[i]);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }
            stdTerm = TermsMgr.GetInstance().GetStandardTerms("Category");
            for (int i = 0; i < state.CategoryNames.Count(); i++)
            {
                writer.WriteStartElement(stdTerm);
                writer.WriteStartAttribute(TermsMgr.GetInstance().GetStandardTerms("field:Title"));
                writer.WriteValue(state.CategoryNames[i]);
                writer.WriteEndAttribute();
                writer.WriteEndElement();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Registers the terms.
 /// </summary>
 /// <param name="term">The term.</param>
 /// <param name="stdTerm">The STD term.</param>
 /// <returns>
 ///     <c>true</c> if the registration was successful; otherwise <c>false</c>.
 /// </returns>
 protected bool RegisterTerms(string term, string stdTerm)
 {
     return(TermsMgr.GetInstance().RegisterMapping(term, TermsNamespace + ":" + stdTerm));
 }