public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                     values)
        {
            System.Collections.Generic.IList <object> l = (System.Collections.Generic.IList <object
                                                                                             >)values[attributeName];
            int localFromIndex = fromIndex;
            int localEndIndex  = fromIndex + size;

            // If not throw exception, we must implement
            // Index Out Of Bound protection
            if (!throwExceptionIfOutOfBound)
            {
                // Check from index
                if (localFromIndex > l.Count - 1)
                {
                    localFromIndex = 0;
                }
                // Check end index
                if (localEndIndex > l.Count)
                {
                    localEndIndex = l.Count;
                }
            }
            sublist = new NeoDatis.Odb.Impl.Core.Query.List.Objects.LazySimpleListOfAOI <object
                                                                                         >(size, GetInstanceBuilder(), ReturnInstance());
            sublist.AddAll(NeoDatis.Tool.Wrappers.List.NeoDatisCollectionUtil.SublistGeneric(
                               l, localFromIndex, localEndIndex));
        }
Example #2
0
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     System.Decimal n = (System.Decimal)values[attributeName];
     sum = NeoDatis.Tool.Wrappers.NeoDatisNumber.Add(sum, NeoDatis.Odb.Impl.Core.Query.Values.ValuesUtil
                                                     .Convert(n));
 }
Example #3
0
 private void Compute(NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values
                      )
 {
     for (int i = 0; i < returnArraySize; i++)
     {
         queryFieldActions[i].Execute(values.GetObjectInfoHeader().GetOid(), values);
     }
 }
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
     ()
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                       ();
     map.Add(attributeName, criterionValue);
     return(map);
 }
Example #5
0
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     System.Decimal n = NeoDatis.Odb.Impl.Core.Query.Values.ValuesUtil.Convert((System.Decimal
                                                                                )values[attributeName]);
     myValue = myValue.Add(new System.Decimal(n.ToString()).Multiply(new System.Decimal
                                                                         (2)));
 }
Example #6
0
 /// <summary>Take the fields of the index and take value from the query</summary>
 /// <param name="ci">The class info involved</param>
 /// <param name="index">The index</param>
 /// <param name="query"></param>
 /// <returns>The key of the index</returns>
 public static NeoDatis.Tool.Wrappers.OdbComparable ComputeKey(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                               ci, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index, NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                               query)
 {
     string[] attributesNames = ci.GetAttributeNames(index.GetAttributeIds());
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = query.GetCriteria
                                                                          ().GetValues();
     return(BuildIndexKey(index.GetName(), values, attributesNames));
 }
Example #7
0
        public override bool Match(object valueToMatch)
        {
            // If it is a AttributeValuesMap, then gets the real value from the map
            // AttributeValuesMap is used to optimize Criteria Query
            // (reading only values of the object that the query needs to be
            // evaluated instead of reading the entire object)
            if (valueToMatch is NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap)
            {
                NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap attributeValues = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                                           )valueToMatch;
                valueToMatch = attributeValues.GetAttributeValue(attributeName);
            }
            if (valueToMatch == null && criterionValue == null && oid == null)
            {
                return(true);
            }
            // if case sensitive (default value), just call the equals on the
            // objects
            if (isCaseSensitive)
            {
                if (objectIsNative)
                {
                    return(valueToMatch != null && NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.AttributeValueComparator
                           .Equals(valueToMatch, criterionValue));
                }
                NeoDatis.Odb.OID objectOid = (NeoDatis.Odb.OID)valueToMatch;
                if (oid == null)
                {
                    // TODO Should we return false or thrown exception?
                    // See junit TestCriteriaQuery6.test1
                    return(false);
                }
                // throw new
                // ODBRuntimeException(NeoDatisError.CRITERIA_QUERY_ON_UNKNOWN_OBJECT);
                return(oid.Equals(objectOid));
            }
            // && valueToMatch.equals(criterionValue);
            // Case insensitive (iequal) only works on String or Character!
            bool canUseCaseInsensitive = (criterionValue.GetType() == typeof(string) && valueToMatch
                                          .GetType() == typeof(string)) || (criterionValue.GetType() == typeof(char) && valueToMatch
                                                                            .GetType() == typeof(char));

            if (!canUseCaseInsensitive)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryAttributeTypeNotSupportedInIequalExpression
                                                           .AddParameter(valueToMatch.GetType().FullName));
            }
            // Cast to string to make the right comparison using the
            // equalsIgnoreCase
            string s1 = (string)valueToMatch;
            string s2 = (string)criterionValue;

            return(NeoDatis.Tool.Wrappers.OdbString.EqualsIgnoreCase(s1, s2));
        }
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     System.Decimal n  = (System.Decimal)values[attributeName];
     System.Decimal bd = NeoDatis.Odb.Impl.Core.Query.Values.ValuesUtil.Convert(n);
     if (minValue.CompareTo(bd) > 0)
     {
         oidOfMinValues = oid;
         minValue       = bd;
     }
 }
Example #9
0
 public override bool Match(object valueToMatch)
 {
     // If it is a AttributeValuesMap, then gets the real value from the map
     if (valueToMatch is NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap)
     {
         NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap attributeValues = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                                    )valueToMatch;
         valueToMatch = attributeValues[attributeName];
     }
     return(valueToMatch == null);
 }
        public override bool Match(object valueToMatch)
        {
            if (valueToMatch == null && criterionValue == null)
            {
                return(true);
            }
            NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap attributeValues = null;
            // If it is a AttributeValuesMap, then gets the real value from the map
            if (valueToMatch is NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap)
            {
                attributeValues = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap)valueToMatch;
                valueToMatch    = attributeValues.GetAttributeValue(attributeName);
            }
            if (valueToMatch == null)
            {
                return(false);
            }
            if (!(valueToMatch is System.IComparable))
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryComparableCriteriaAppliedOnNonComparable
                                                           .AddParameter(valueToMatch.GetType().FullName));
            }
            System.IComparable comparable1 = (System.IComparable)valueToMatch;
            System.IComparable comparable2 = (System.IComparable)criterionValue;
            switch (comparisonType)
            {
            case ComparisonTypeGt:
            {
                return(valueToMatch != null && NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.AttributeValueComparator
                       .Compare(comparable1, comparable2) > 0);
            }

            case ComparisonTypeGe:
            {
                return(valueToMatch != null && NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.AttributeValueComparator
                       .Compare(comparable1, comparable2) >= 0);
            }

            case ComparisonTypeLt:
            {
                return(valueToMatch != null && NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.AttributeValueComparator
                       .Compare(comparable1, comparable2) < 0);
            }

            case ComparisonTypeLe:
            {
                return(valueToMatch != null && NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.AttributeValueComparator
                       .Compare(comparable1, comparable2) <= 0);
            }
            }
            throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryUnknownOperator
                                                       .AddParameter(comparisonType));
        }
Example #11
0
        /// <summary>The method that actually computes the logins</summary>
        public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                     values)
        {
            // Gets the name of the user
            string userName = (string)values["name"];

            // Call an external class (Users) to check if the user is logged in
            if (NeoDatis.Odb.Test.Query.Values.Sessions.IsLogged(userName))
            {
                nbLoggedUsers++;
            }
        }
		public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
			()
		{
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
				();
			System.Collections.IEnumerator iterator = criteria.GetEnumerator();
			NeoDatis.Odb.Core.Query.Criteria.ICriterion criterion = null;
			while (iterator.MoveNext())
			{
				criterion = (NeoDatis.Odb.Core.Query.Criteria.ICriterion)iterator.Current;
				map.PutAll(criterion.GetValues());
			}
			return map;
		}
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
     ()
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                       ();
     System.Collections.IEnumerator iterator = criteria.GetEnumerator();
     NeoDatis.Odb.Core.Query.Criteria.ICriterion criterion = null;
     while (iterator.MoveNext())
     {
         criterion = (NeoDatis.Odb.Core.Query.Criteria.ICriterion)iterator.Current;
         map.PutAll(criterion.GetValues());
     }
     return(map);
 }
Example #14
0
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
     ()
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                       ();
     if (criterionValue == null && oid != null)
     {
         map.SetOid(oid);
     }
     else
     {
         map.Add(attributeName, criterionValue);
     }
     return(map);
 }
Example #15
0
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     this.value = values[attributeName];
     if (NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.IsCollection(this.value.GetType(
                                                                       )))
     {
         // For collection,we encapsulate it in an lazy load list that will create objects on demand
         System.Collections.Generic.ICollection <object> c = (System.Collections.Generic.ICollection
                                                              <object>) this.value;
         NeoDatis.Odb.Impl.Core.Query.List.Objects.LazySimpleListOfAOI <object> l = new NeoDatis.Odb.Impl.Core.Query.List.Objects.LazySimpleListOfAOI
                                                                                    <object>(c.Count, GetInstanceBuilder(), ReturnInstance());
         l.AddAll(c);
         this.value = l;
     }
 }
Example #16
0
 // This method os not used in Values Query API
 public virtual void ObjectMatch(NeoDatis.Odb.OID oid, object @object, NeoDatis.Tool.Wrappers.OdbComparable
                                 orderByKey)
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                       )@object;
     NeoDatis.Tool.Wrappers.OdbComparable groupByKey = NeoDatis.Odb.Core.Query.Execution.IndexTool
                                                       .BuildIndexKey("GroupBy", values, groupByFieldList);
     NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction result = groupByResult
                                                                          [groupByKey];
     if (result == null)
     {
         result = new NeoDatis.Odb.Impl.Core.Query.Values.ValuesQueryResultAction(query, null
                                                                                  , instanceBuilder);
         result.Start();
         groupByResult.Add(groupByKey, result);
     }
     result.ObjectMatch(oid, @object, orderByKey);
 }
Example #17
0
 public static NeoDatis.Tool.Wrappers.OdbComparable BuildIndexKey(string indexName
                                                                  , NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values, string[] fields
                                                                  )
 {
     if (fields.Length == 1)
     {
         return(new NeoDatis.Odb.Core.Query.SimpleCompareKey(values.GetComparable(fields[0
                                                                                  ])));
     }
     NeoDatis.Tool.Wrappers.OdbComparable[] keys = new NeoDatis.Tool.Wrappers.OdbComparable
                                                   [fields.Length];
     System.IComparable @object = null;
     for (int i = 0; i < fields.Length; i++)
     {
         // Todo : can we assume that the object is a Comparable
         try
         {
             @object = (System.IComparable)values[fields[i]];
             // JDK1.4 restriction: Boolean is not Comparable in jdk1.4
             if (@object is bool)
             {
                 bool b = (bool)@object;
                 if (b)
                 {
                     @object = (byte)1;
                 }
                 else
                 {
                     @object = (byte)0;
                 }
             }
             keys[i] = new NeoDatis.Odb.Core.Query.SimpleCompareKey(@object);
         }
         catch (System.Exception)
         {
             throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IndexKeysMustImplementComparable
                                                        .AddParameter(indexName).AddParameter(fields[i]).AddParameter(values[fields[i]].
                                                                                                                      GetType().FullName));
         }
     }
     NeoDatis.Odb.Core.Query.ComposedCompareKey key = new NeoDatis.Odb.Core.Query.ComposedCompareKey
                                                          (keys);
     return(key);
 }
		public override bool MatchObjectWithOid(NeoDatis.Odb.OID oid, bool returnObject, 
			bool inMemory)
		{
			currentOid = oid;
			// Gets a map with the values with the fields involved in the query
			values = objectReader.ReadObjectInfoValuesFromOID(classInfo, currentOid, true, involvedFields
				, involvedFields, 0, criteriaQuery.GetOrderByFieldNames());
			bool objectMatches = true;
			if (!criteriaQuery.IsForSingleOid())
			{
				// Then apply the query on the field values
				objectMatches = NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQueryManager.Match(
					criteriaQuery, values);
			}
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = values.GetObjectInfoHeader
				();
			// Stores the next position
			nextOID = oih.GetNextObjectOID();
			return objectMatches;
		}
Example #19
0
 public override bool Match(object valueToMatch)
 {
     // If it is a AttributeValuesMap, then gets the real value from the map
     if (valueToMatch is NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap)
     {
         NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap attributeValues = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                                    )valueToMatch;
         valueToMatch = attributeValues.GetAttributeValue(attributeName);
     }
     if (valueToMatch == null)
     {
         // Null list are considered 0-sized list
         if (sizeType == SizeEq && size == 0)
         {
             return(true);
         }
         if ((sizeType == SizeLe && size >= 0) || (sizeType == SizeLt && size > 0))
         {
             return(true);
         }
         if (sizeType == SizeNe && size != 0)
         {
             return(true);
         }
         return(false);
     }
     if (valueToMatch is System.Collections.ICollection)
     {
         System.Collections.ICollection c = (System.Collections.ICollection)valueToMatch;
         return(MatchSize(c.Count, size, sizeType));
     }
     System.Type clazz = valueToMatch.GetType();
     if (clazz.IsArray)
     {
         int arrayLength = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayLength(valueToMatch
                                                                               );
         return(MatchSize(arrayLength, size, sizeType));
     }
     throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryBadCriteria
                                                .AddParameter(valueToMatch.GetType().FullName));
 }
Example #20
0
        public override bool MatchObjectWithOid(NeoDatis.Odb.OID oid, bool returnObject,
                                                bool inMemory)
        {
            currentOid = oid;
            // Gets a map with the values with the fields involved in the query
            values = objectReader.ReadObjectInfoValuesFromOID(classInfo, currentOid, true, involvedFields
                                                              , involvedFields, 0, criteriaQuery.GetOrderByFieldNames());
            bool objectMatches = true;

            if (!criteriaQuery.IsForSingleOid())
            {
                // Then apply the query on the field values
                objectMatches = NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQueryManager.Match(
                    criteriaQuery, values);
            }
            NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = values.GetObjectInfoHeader
                                                                            ();
            // Stores the next position
            nextOID = oih.GetNextObjectOID();
            return(objectMatches);
        }
Example #21
0
 private NeoDatis.Odb.ObjectValues ConvertObject(NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                 values)
 {
     NeoDatis.Odb.Impl.Core.Query.List.Values.DefaultObjectValues dov = new NeoDatis.Odb.Impl.Core.Query.List.Values.DefaultObjectValues
                                                                            (returnArraySize);
     NeoDatis.Odb.Core.Query.Execution.IQueryFieldAction qfa = null;
     for (int i = 0; i < returnArraySize; i++)
     {
         qfa = queryFieldActions[i];
         qfa.Execute(values.GetObjectInfoHeader().GetOid(), values);
         object o = qfa.GetValue();
         // When Values queries return objects, they actually return the oid of the object
         // So we must load it here
         if (o != null && o is NeoDatis.Odb.OID)
         {
             NeoDatis.Odb.Impl.Core.Oid.OdbObjectOID oid = (NeoDatis.Odb.Impl.Core.Oid.OdbObjectOID
                                                            )o;
             o = engine.GetObjectFromOid(oid);
         }
         dov.Set(i, qfa.GetAlias(), o);
     }
     return(dov);
 }
Example #22
0
 public abstract void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values);
Example #23
0
 public virtual bool Match(NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                           attributeValues)
 {
     return(Match(attributeValues.GetAttributeValue(attributeName)));
 }
Example #24
0
 public virtual NeoDatis.Tool.Wrappers.OdbComparable BuildOrderByKey(NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                                                                     values)
 {
     return(NeoDatis.Odb.Core.Query.Execution.IndexTool.BuildIndexKey("OrderBy", values
                                                                      , query.GetOrderByFieldNames()));
 }
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     count = NeoDatis.Tool.Wrappers.NeoDatisNumber.Add(count, One);
 }
 public override void Execute(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
                              values)
 {
     System.Collections.IList l = (System.Collections.IList)values[attributeName];
     this.size = l.Count;
 }
		public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
			()
		{
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
				();
			map.Add(attributeName, criterionValue);
			return map;
		}
		public override NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap GetValues
			()
		{
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap map = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap
				();
			if (criterionValue == null && oid != null)
			{
				map.SetOid(oid);
			}
			else
			{
				map.Add(attributeName, criterionValue);
			}
			return map;
		}