public virtual ClassInfoIndex AddIndexOn(string
                                                 name, string[] indexFields, bool acceptMultipleValuesForSameKey)
        {
            if (indexes == null)
            {
                indexes = new NeoDatis.Tool.Wrappers.List.OdbArrayList <ClassInfoIndex
                                                                        >();
            }
            ClassInfoIndex cii = new ClassInfoIndex
                                     ();

            cii.SetClassInfoId(id);
            cii.SetCreationDate(NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs());
            cii.SetLastRebuild(cii.GetCreationDate());
            cii.SetName(name);
            cii.SetStatus(ClassInfoIndex.Enabled);
            cii.SetUnique(!acceptMultipleValuesForSameKey);
            int[] attributeIds = new int[indexFields.Length];
            for (int i = 0; i < indexFields.Length; i++)
            {
                attributeIds[i] = GetAttributeId(indexFields[i]);
            }
            cii.SetAttributeIds(attributeIds);
            indexes.Add(cii);
            return(cii);
        }
Exemple #2
0
 public override System.IComparable ComputeIndexKey(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                    ci, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index)
 {
     NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              )query;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = q.GetCriteria().
                                                                      GetValues();
     // if values.hasOid() is true, this means that we are working of the full object,
     // the index key is then the oid and not the object itself
     if (values.HasOid())
     {
         return(new NeoDatis.Odb.Core.Query.SimpleCompareKey(values.GetOid()));
     }
     return(NeoDatis.Odb.Core.Query.Execution.IndexTool.ComputeKey(classInfo, index, (
                                                                       NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query));
 }
        public virtual bool HasIndex(string indexName)
        {
            ClassInfoIndex cii = null;

            if (indexes == null)
            {
                return(false);
            }
            for (int i = 0; i < indexes.Count; i++)
            {
                cii = indexes[i];
                if (indexName.Equals(cii.GetName()))
                {
                    return(true);
                }
            }
            return(false);
        }
        public virtual ClassInfoIndex GetIndexForAttributeIds
            (int[] attributeIds)
        {
            ClassInfoIndex cii = null;

            if (indexes == null)
            {
                return(null);
            }
            for (int i = 0; i < indexes.Count; i++)
            {
                cii = indexes[i];
                if (cii.MatchAttributeIds(attributeIds))
                {
                    return(cii);
                }
            }
            return(null);
        }
        public virtual ClassInfoIndex GetIndexForAttributeId
            (int attributeId)
        {
            ClassInfoIndex cii = null;

            if (indexes == null)
            {
                return(null);
            }
            for (int i = 0; i < indexes.Count; i++)
            {
                cii = indexes[i];
                if (cii.GetAttributeIds().Length == 1 && cii.GetAttributeId(0) == attributeId)
                {
                    return(cii);
                }
            }
            return(null);
        }
        public virtual ClassInfoIndex GetIndexWithName
            (string name)
        {
            ClassInfoIndex cii = null;

            if (indexes == null)
            {
                return(null);
            }
            for (int i = 0; i < indexes.Count; i++)
            {
                cii = indexes[i];
                if (cii.GetName().Equals(name))
                {
                    return(cii);
                }
            }
            return(null);
        }
		/// <summary>Removes an index</summary>
		/// <param name="cii"></param>
		public virtual void RemoveIndex(ClassInfoIndex
			 cii)
		{
			indexes.Remove(cii);
		}
		public virtual ClassInfoIndex AddIndexOn(string
			 name, string[] indexFields, bool acceptMultipleValuesForSameKey)
		{
			if (indexes == null)
			{
				indexes = new NeoDatis.Tool.Wrappers.List.OdbArrayList<ClassInfoIndex
					>();
			}
			ClassInfoIndex cii = new ClassInfoIndex
				();
			cii.SetClassInfoId(id);
			cii.SetCreationDate(NeoDatis.Tool.Wrappers.OdbTime.GetCurrentTimeInMs());
			cii.SetLastRebuild(cii.GetCreationDate());
			cii.SetName(name);
			cii.SetStatus(ClassInfoIndex.Enabled);
			cii.SetUnique(!acceptMultipleValuesForSameKey);
			int[] attributeIds = new int[indexFields.Length];
			for (int i = 0; i < indexFields.Length; i++)
			{
				attributeIds[i] = GetAttributeId(indexFields[i]);
			}
			cii.SetAttributeIds(attributeIds);
			indexes.Add(cii);
			return cii;
		}
 /// <summary>Removes an index</summary>
 /// <param name="cii"></param>
 public virtual void RemoveIndex(ClassInfoIndex
                                 cii)
 {
     indexes.Remove(cii);
 }