Ejemplo n.º 1
0
        private static IEnumerable <MetadataClass> ParseClasses(XNamespace ns, IEnumerable <XElement> classElements)
        {
            var classes = new List <MetadataClass>();

            foreach (var classElem in classElements)
            {
                var metadataClass = new MetadataClass();
                metadataClass.ClassName        = classElem.Descendants(ns + "ClassName").FirstOrDefault()?.Value;
                metadataClass.StandardName     = classElem.Descendants(ns + "StandardName").FirstOrDefault()?.Value;
                metadataClass.VisibleName      = classElem.Descendants(ns + "VisibleName").FirstOrDefault()?.Value;
                metadataClass.Description      = classElem.Descendants(ns + "Description").FirstOrDefault()?.Value;
                metadataClass.TableVersion     = classElem.Descendants(ns + "TableVersion").FirstOrDefault()?.Value;
                metadataClass.TableDate        = classElem.Descendants(ns + "TableDate").FirstOrDefault()?.Value;
                metadataClass.UpdateVersion    = classElem.Descendants(ns + "UpdateVersion").FirstOrDefault()?.Value;
                metadataClass.UpdateDate       = classElem.Descendants(ns + "UpdateDate").FirstOrDefault()?.Value;
                metadataClass.ClassTimestamp   = classElem.Descendants(ns + "ClassTimeStamp").FirstOrDefault()?.Value;
                metadataClass.DeletedFlagField = classElem.Descendants(ns + "DeletedFlagField").FirstOrDefault()?.Value;
                metadataClass.DeletedFlagField = classElem.Descendants(ns + "DeletedFlagValue").FirstOrDefault()?.Value;
                metadataClass.HasKeyIndex      = classElem.Descendants(ns + "HasKeyIndex").FirstOrDefault()?.Value;

                var tableElements = classElem.Descendants(ns + "METADATA-TABLE");
                metadataClass.Tables = ParseTables(ns, tableElements);

                classes.Add(metadataClass);
            }

            return(classes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a spatial metadata class mapping to NHibernate configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="clazz">The clazz.</param>
        /// <remarks>
        /// DO NOT add metadata class mappings when using the SchemaExport utility.
        /// You could lose all contents of those tables.
        /// </remarks>
        public static void AddMapping(Configuration configuration, MetadataClass clazz)
        {
            NHibernate.Dialect.Dialect dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);

            string resource = typeof(Metadata).Namespace
                + "."
                + clazz.ToString()
                + "."
                + dialect.GetType().Name
                + ".hbm.xml";

            configuration.AddResource(resource, dialect.GetType().Assembly);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add a spatial metadata class mapping to NHibernate configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="clazz">The clazz.</param>
        /// <remarks>
        /// DO NOT add metadata class mappings when using the SchemaExport utility.
        /// You could lose all contents of those tables.
        /// </remarks>
        public static void AddMapping(Configuration configuration, MetadataClass clazz)
        {
            NHibernate.Dialect.Dialect dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);

            string resource = typeof(Metadata).Namespace
                              + "."
                              + clazz.ToString()
                              + "."
                              + dialect.GetType().Name
                              + ".hbm.xml";

            configuration.AddResource(resource, dialect.GetType().Assembly);
        }
Ejemplo n.º 4
0
        static void dumpAllTables(RetsMetadata metadata, MetadataClass aClass)
        {
            IEnumerable tables = metadata.GetAllTables(aClass);

            foreach (MetadataTable table in tables)
            {
                Console.WriteLine("Table name: " + table.GetSystemName() + " [" +
                                  table.GetStandardName() + "]");
                Console.WriteLine("\tTable datatype: " + table.GetDataType());
                Console.WriteLine("\tUnique: " + table.IsUnique());
                Console.WriteLine("\tMax Length: " + table.GetMaximumLength());
            }
        }
Ejemplo n.º 5
0
 static void dumpAllTables(RetsMetadata metadata, MetadataClass aClass)
 {
     IEnumerable tables = metadata.GetAllTables(aClass);
     foreach (MetadataTable table in tables)
     {
         Console.WriteLine("Table name: " + table.GetSystemName() + " [" +
             table.GetStandardName() + "]");
         Console.WriteLine("\tTable datatype: " + table.GetDataType());
         Console.WriteLine("\tUnique: " + table.IsUnique());
         Console.WriteLine("\tMax Length: " + table.GetMaximumLength());
         if (table.InKeyIndex())
             Console.WriteLine("\tInKeyIndex");
     }
 }
Ejemplo n.º 6
0
            public LoadPlan EnsurePlan(MetadataClass cls)
            {
                for (int index = 0; index < this.PlansByClass.Count; ++index)
                {
                    LoadPlan loadPlan = this.PlansByClass[index];
                    if (loadPlan.Class == cls)
                    {
                        return(loadPlan);
                    }
                }
                LoadPlan loadPlan1 = this.Builder.BuildPlan(cls, this.SourceNode);

                this.PlansByClass.Add(loadPlan1);
                return(loadPlan1);
            }
        /// <summary>
        ///   A linkTable entity contains many properties that can be annotated as KeyAttribute. In this method we mark all of them to be excluded (using the ExceludeAttribute), except for
        ///   those of them that are actually allocated as key properties. This way, the generated entity at the client will only have properties that really are KeyAttributes.
        /// </summary>
        /// <param name="metaData"> </param>
        private void MarkLinkTableKeysAsDataMembers(MetadataClass <TLinkTable> metaData)
        {
            var linkTableMetaData = _metaDataContainer.Entity <TLinkTable>();

            var typeDescr = _metaDataContainer.GetTypeDescriptor(typeof(TLinkTable));

            foreach (var propDescr in typeDescr.GetProperties().OfType <PropertyDescriptor>())
            {
                var memberMetadata = metaData.GetMemberMetadata(propDescr.Name);
                if (memberMetadata == null
                    ||
                    (memberMetadata.OfType <KeyAttribute>().Any() == false &&
                     memberMetadata.OfType <AssociationAttribute>().Any() == false))
                {
                    linkTableMetaData.AddMetadata(propDescr.Name, new ExcludeAttribute());
                }
            }
        }
		public bool SupportsSpatialMetadata(MetadataClass metadataClass)
		{
			return worker.SupportsSpatialMetadata(metadataClass);
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Gets a value indicating whether it supports spatial metadata.
 /// </summary>
 /// <value>
 ///     <c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 public bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     return(true);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets a value indicating whether it supports spatial metadata.
 /// </summary>
 /// <value>
 /// 	<c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 public bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     return metadataClass == MetadataClass.GeometryColumn;
 }
Ejemplo n.º 11
0
 public bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     return(worker.SupportsSpatialMetadata(metadataClass));
 }
Ejemplo n.º 12
0
 public AssociationNavigator(string associationPropertyName, MetadataClass refClass)
 {
     this.FAssociationPropertyName = associationPropertyName;
     this.FRefClass = refClass;
 }
 /// <summary>
 /// Gets a value indicating whether it supports spatial metadata.
 /// </summary>
 /// <value>
 ///     <c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 public virtual bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     //return metadataClass == MetadataClass.GeometryColumn;
     return(false);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Gets a value indicating whether it supports spatial metadata.
 /// </summary>
 /// <value>
 ///     <c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 public bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     return(metadataClass == MetadataClass.GeometryColumn);
 }
Ejemplo n.º 15
0
    /*
     * This class demonstrates the interleaving of search transactions.
     */
    static void Main(string[] args)
    {
        Options options = new Options();

        if (!options.Parse(args))
        {
            Environment.Exit(1);
        }

        RetsSession session = options.SessionFactory();

        try {
            if (!session.Login(options.user_name, options.user_password))
            {
                Console.WriteLine("Invalid login");
                Environment.Exit(1);
            }
        } catch (Exception e)
        {
            Console.WriteLine("RetsException: " + e);
            Environment.Exit(1);
        }

        RetsVersion version = session.GetDetectedRetsVersion();

        Console.WriteLine("RETS Version: " +
                          ((version == RetsVersion.RETS_1_5) ? "1.5" :
                           ((version == RetsVersion.RETS_1_7) ? "1.7" : "1.0")));

        /*
         * Find the key field for the resource.
         */
        RetsMetadata     metadata         = session.GetMetadata();
        MetadataResource metadataResource = metadata.GetResource(options.search_type);

        if (metadataResource == null)
        {
            Console.WriteLine("Invalid resource: " + options.search_type);
            session.Logout();
            Environment.Exit(1);
        }

        string keyField = metadataResource.GetKeyField();

        /*
         * Find the timestamp field if it is known (RETS 1.7 and later). If
         * not known, then the user must provide it.
         */
        MetadataClass metadataClass = metadata.GetClass(options.search_type, options.search_class);

        if (metadataClass == null)
        {
            Console.WriteLine("Invalid resource:class: " + options.search_type + ":" + options.search_class);
            session.Logout();
            Environment.Exit(2);
        }

        if (options.classTimeStamp != null && options.classTimeStamp.Length == 0)
        {
            options.classTimeStamp = metadataClass.GetStringAttribute("ClassTimeStamp");
        }

        if (options.classTimeStamp == null || options.classTimeStamp.Length == 0)
        {
            Console.WriteLine("Class " + options.search_type +
                              ":" + options.search_class +
                              " has no ClassTimeStamp specified in the metadata.");
            Console.WriteLine("Please manually provide one using the --timetsamp switch.");
            session.Logout();
            Environment.Exit(2);
        }

        /*
         * See if the last modified timestamp has been provided. If not, use yesterday.
         */
        if (options.lastModified == null || options.lastModified.Length == 0)
        {
            DateTime ts = DateTime.Now;

            options.lastModified = ts.AddDays(-1).ToString("yyyy-MM-dd");
        }

        /*
         * OK - let's find all listings that have changed since the lastModified date.
         */

        SearchRequest searchRequest = session.CreateSearchRequest(
            options.search_type,
            options.search_class,
            "(" +
            options.classTimeStamp.ToString() +
            "=" +
            options.lastModified.ToString() +
            "+)");

        searchRequest.SetSelect(keyField);
        searchRequest.SetLimit(SearchRequest.LIMIT_NONE);
        searchRequest.SetOffset(SearchRequest.OFFSET_NONE);
        searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);
        searchRequest.SetStandardNames(false);

        /*
         * This starts the outer search.
         */
        SearchResultSet results = session.Search(searchRequest);

        Console.WriteLine("Record count: " + results.GetCount());
        Console.WriteLine();

        while (results.HasNext())
        {
            /*
             * Fetch the listing detail and media. This will cause a separate search transaction
             * to be open within the outer search transaction.
             */
            SearchRequest listingRequest = session.CreateSearchRequest(
                options.search_type,
                options.search_class,
                "(" +
                keyField +
                "=" +
                results.GetString(keyField) +
                ")");
            listingRequest.SetStandardNames(false);
            listingRequest.SetLimit(SearchRequest.LIMIT_DEFAULT);
            listingRequest.SetOffset(SearchRequest.OFFSET_NONE);
            listingRequest.SetCountType(SearchRequest.CountType.NO_RECORD_COUNT);
            listingRequest.SetFormatType(SearchRequest.FormatType.COMPACT);

            SearchResultSet listingResult = session.Search(listingRequest);
            IEnumerable     columns       = null;

            while (listingResult.HasNext())
            {
                if (columns == null)
                {
                    columns = listingResult.GetColumns();
                }

                /*
                 * Show the listing detail.
                 */
                foreach (string column in columns)
                {
                    Console.WriteLine("{0,15}: {1}", column, listingResult.GetString(column));
                }
                Console.WriteLine();

                /*
                 * Now set up to fetch the objects associated with this listing.
                 */
                GetObjectRequest getObjectRequest = new GetObjectRequest(options.search_type, "Photo");
                getObjectRequest.AddAllObjects(listingResult.GetString(keyField));

                GetObjectResponse getObjectResponse = session.GetObject(getObjectRequest);

                foreach (ObjectDescriptor objectDescriptor in getObjectResponse)
                {
                    /*
                     * Report the object details.
                     */
                    string objectKey = objectDescriptor.GetObjectKey();
                    int    objectId  = objectDescriptor.GetObjectId();
                    //string  contentType = objectDescriptor.GetContentType();
                    string description = objectDescriptor.GetDescription();

                    Console.Write("Object " + objectKey + ":" + objectId.ToString());
                    if (description.Length > 0)
                    {
                        Console.Write(", description: " + description);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("=================");
            }
        }

        session.Logout();
    }
		/// <summary>
		/// Gets a value indicating whether it supports spatial metadata.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
		/// </value>
		public virtual bool SupportsSpatialMetadata(MetadataClass metadataClass)
		{
			//return metadataClass == MetadataClass.GeometryColumn;
			return false;
		}
Ejemplo n.º 17
0
        /// <summary>
        /// Gets a value indicating whether the session supports spatial metadata.
        /// </summary>
        /// <value>
        ///     <c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
        /// </value>
        /// <param name="session">The session</param>
        /// <param name="metadataClass">The metadata class</param>
        public static bool SupportsSpatialMetadata(ISession session, MetadataClass metadataClass)
        {
            ISpatialDialect spatialDialect = (ISpatialDialect)((ISessionFactoryImplementor)session.SessionFactory).Dialect;

            return(spatialDialect.SupportsSpatialMetadata(metadataClass));
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets a value indicating whether the session supports spatial metadata.
 /// </summary>
 /// <value>
 /// 	<c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 /// <param name="session">The session</param>
 /// <param name="metadataClass">The metadata class</param>
 public static bool SupportsSpatialMetadata(ISession session, MetadataClass metadataClass)
 {
     ISpatialDialect spatialDialect = (ISpatialDialect)((ISessionFactoryImplementor)session.SessionFactory).Dialect;
     return spatialDialect.SupportsSpatialMetadata(metadataClass);
 }
 /// <summary>
 /// Gets a value indicating whether it supports spatial metadata.
 /// </summary>
 /// <value>
 /// 	<c>true</c> if it supports spatial metadata; otherwise, <c>false</c>.
 /// </value>
 public bool SupportsSpatialMetadata(MetadataClass metadataClass)
 {
     return true;
 }
Ejemplo n.º 20
0
 public MemberProjectionCollectionMetadata(MetadataClass <TModel> metadata, string memberName)
     : base(metadata, memberName)
 {
 }