Exemple #1
0
        public Guid[] FindObjects(IndexData indexData, Type OIDClass, bool complexExtension, out int?readedObjects)
        {
            int           ro;
            IntBinaryTree BT  = getStorageData(indexData);
            List <Guid>   ret = BT.GetObjectsFromBT(OIDClass, out ro);

            readedObjects = ro;

            if (complexExtension)
            {
                foreach (Type t in BT.GetObjectsTypesFromBT().Where(t => t != OIDClass))
                {
                    bool found    = false;
                    Type baseType = t.BaseType;
                    while (baseType != null && !found)
                    {
                        if (baseType == OIDClass)
                        {
                            ret.AddRange(BT.GetObjectsFromBT(OIDClass, out ro));
                            readedObjects += ro;
                            found          = true;
                        }
                        baseType = baseType.BaseType;
                    }
                }
            }

            return(ret.Distinct().ToArray());
        }
Exemple #2
0
        public IndexData RemoveObject(IndexData indexData, Oid obj, string[] attributes, QueryParameters queryParameters)
        {
            IntBinaryTree BT = getStorageData(indexData);

            FieldInfo[] objFields = obj.GetType().GetFields();

            foreach (String attribute in attributes)
            {
                if (objFields.Count(p => p.Name == attribute) != 1)
                {
                    throw new WrongAttributeException <Type>(obj.GetType(), attribute,
                                                             "Nie odnaleziono podanego atrybutu w wskazanym obiekcie");
                }
                //else if (objFields.Single(p => p.Name == attribute).GetType() != typeof(int))
                //    throw new WrongTypeToIndexException(objFields.Single(p => p.Name == attribute).GetType(), string.Format("Unnsupported type of attribiute {0}", attribute));
            }

            foreach (String attribute in attributes)
            {
                if (objFields.Single(p => p.Name == attribute).GetType() == typeof(int))
                {
                    int attributeValue = (int)objFields.Where(p => p.Name == attribute).Single().GetValue(obj);
                    BT.RemoveFromBTvalue(obj, attribute, attributeValue);
                }
            }

            return(BT);
        }
Exemple #3
0
        public Guid[] FindObjects(IndexData indexData, Type OIDClass, bool complexExtension, string[] attributes,
                                  object[] values, CompareType[] compareTypes, out int?readedObjects)
        {
            if (compareTypes.Count() != attributes.Count() || attributes.Count() != values.Count())
            {
                throw new ArgumentException(
                          "Liczności tbalic z atrybutami, porównaniami oraz wartościami musza być identyczne!");
            }

            readedObjects = 0;
            int           ro;
            IntBinaryTree BT  = getStorageData(indexData);
            List <Guid>   ret = null;

            for (int i = 0; i < attributes.Count(); i++)
            {
                List <Guid> foundOIDs = BT.GetObjectsFromBT(OIDClass, attributes[i], (int)values[i], compareTypes[i],
                                                            out ro);
                readedObjects += ro;

                if (complexExtension)
                {
                    foreach (Type t in BT.GetObjectsTypesFromBT().Where(t => t != OIDClass))
                    {
                        bool found    = false;
                        Type baseType = t.BaseType;
                        while (baseType != null && !found)
                        {
                            if (baseType == OIDClass)
                            {
                                foundOIDs.AddRange(BT.GetObjectsFromBT(OIDClass, attributes[i], (int)values[i],
                                                                       compareTypes[i], out ro));
                                readedObjects += ro;
                                found          = true;
                            }
                            baseType = baseType.BaseType;
                        }
                    }
                }

                if (ret == null)
                {
                    ret = foundOIDs.Distinct().ToList();
                }
                else
                {
                    ret =
                        ret.Intersect(foundOIDs.Distinct()).ToList();
                }
            }

            return(ret.ToArray());
        }
Exemple #4
0
        public IndexData AddObject(IndexData indexData, Oid obj, string[] attributes, QueryParameters queryParameters)
        {
            IntBinaryTree BT = getStorageData(indexData);

            /* FieldInfo[] objFields = obj.GetType().GetFields();
             *
             * foreach (String attribute in attributes)
             * {
             *   if (objFields.Count(p => p.Name == attribute) != 1)
             *       throw new WrongAttributeException(obj.GetType(), attribute,
             *                                         "Nie odnaleziono podanego atrybutu w wskazanym obiekcie");
             *   else if (objFields.Single(p => p.Name == attribute).GetValue(obj).GetType() != typeof (int))
             *       throw new WrongTypeToIndexException(objFields.Single(p => p.Name == attribute).GetType(),
             *                                           string.Format("Unnsupported type of attribiute {0}", attribute));
             * }*/

            foreach (String attribute in attributes)
            {
                // int attributeValue = (int) objFields.Where(p => p.Name == attribute).Single().GetValue(obj);
                BT.AddToBTvalue(obj, attribute, 1);
            }

            return(BT);
        }
Exemple #5
0
        public Guid[] GetIndexedObjects(IndexData indexData, int?packageSize, int skipItemsCount)
        {
            IntBinaryTree BT = getStorageData(indexData);

            return(BT.GetObjectsFromBT());
        }