private bool CheckIfCollectionContainsValue(System.Collections.ICollection c) { NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = GetQuery().GetStorageEngine (); if (engine == null) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.QueryEngineNotSet ); } NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null; System.Collections.IEnumerator iterator = c.GetEnumerator(); // If the object to compared is native if (objectIsNative) { while (iterator.MoveNext()) { aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)iterator.Current; if (aoi == null && criterionValue == null) { return(true); } if (aoi != null && criterionValue == null) { return(false); } if (criterionValue.Equals(aoi.GetObject())) { return(true); } } return(false); } // Object is not native while (iterator.MoveNext()) { aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)iterator.Current; if (aoi.IsNull() && criterionValue == null && oid == null) { return(true); } if (aoi != null & oid != null) { if (aoi.IsNonNativeObject()) { NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi1 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )aoi; bool isEqual = nnoi1.GetOid() != null && oid != null && nnoi1.GetOid().Equals(oid ); if (isEqual) { return(true); } } } } return(false); }
public static NeoDatis.Tool.Wrappers.OdbComparable BuildIndexKey(string indexName , NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oi, int[] fieldIds) { NeoDatis.Tool.Wrappers.OdbComparable[] keys = new NeoDatis.Tool.Wrappers.OdbComparable [fieldIds.Length]; NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null; System.IComparable o = null; for (int i = 0; i < fieldIds.Length; i++) { // Todo : can we assume that the object is a Comparable try { aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)oi.GetAttributeValueFromId (fieldIds[i]); o = (System.IComparable)aoi.GetObject(); // JDK1.4 restriction: Boolean is not Comparable in jdk1.4 if (aoi.GetOdbType().IsBoolean()) { bool b = (bool)o; if (b) { o = (byte)1; } else { o = (byte)0; } } // If the index is on NonNativeObjectInfo, then the key is the oid // of the object if (aoi.IsNonNativeObject()) { NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )aoi; o = nnoi.GetOid(); } keys[i] = new NeoDatis.Odb.Core.Query.SimpleCompareKey(o); } catch (System.Exception) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.IndexKeysMustImplementComparable .AddParameter(fieldIds[i]).AddParameter(oi.GetAttributeValueFromId(fieldIds[i]). GetType().FullName)); } } if (keys.Length == 1) { return(keys[0]); } return(new NeoDatis.Odb.Core.Query.ComposedCompareKey(keys)); }
private bool CheckIfArrayContainsValue(object valueToMatch) { int arrayLength = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayLength(valueToMatch ); object element = null; NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null; for (int i = 0; i < arrayLength; i++) { element = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayElement(valueToMatch, i); if (element == null && criterionValue == null) { return(true); } aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo)element; if (aoi != null && aoi.GetObject() != null && aoi.GetObject().Equals(criterionValue )) { return(true); } } return(false); }
public override T Get(int index) { object o = base[index]; NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo )o; try { if (aoi.IsNull()) { return(default(T)); } if (returnInstance) { if (aoi.IsNative()) { return((T)aoi.GetObject()); } if (instanceBuilder == null) { // Lookup the instance builder instanceBuilder = (NeoDatis.Odb.Core.Layers.Layer2.Instance.IInstanceBuilder)NeoDatis.Odb.Core.Lookup.LookupFactory .Get(sessionId).Get(NeoDatis.Odb.Impl.Core.Lookup.Lookups.InstanceBuilder); if (instanceBuilder == null) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.LookupKeyNotFound .AddParameter(NeoDatis.Odb.Impl.Core.Lookup.Lookups.InstanceBuilder)); } } return((T)instanceBuilder.BuildOneInstance((NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo )aoi)); } // No need to return Instance return the layer 2 representation o = aoi; return((T)o); } catch (System.Exception e) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ErrorWhileGettingObjectFromListAtIndex .AddParameter(index), e); } }