/// <inheritdoc/> protected virtual IProperty ConvertProperty(IObjectType objectType, ICollection <ISecondaryType> secondaryTypes, IPropertyData pd) { IPropertyDefinition definition = objectType[pd.Id]; if (definition == null) { // search secondary types if (secondaryTypes != null) { foreach (ISecondaryType secondaryType in secondaryTypes) { if (secondaryType.PropertyDefinitions != null) { foreach (IPropertyDefinition propertyDefinition in secondaryType.PropertyDefinitions) { if (propertyDefinition.Id == pd.Id) { definition = propertyDefinition; break; } } } } } // property without definition if (definition == null) { throw new CmisRuntimeException("Property '" + pd.Id + "' doesn't exist!"); } } return(CreateProperty(definition, pd.Values)); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IInheritance node, object data) { IObjectType ParentType = (IObjectType)node.ParentType; node.ResolvedParentTypeName.Item = ParentType.ResolvedTypeName.Item; node.ResolvedParentType.Item = ParentType.ResolvedType.Item; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.Include) { var root = extent.Filter.Equals(this); statement.Append(root ? " AND " : "("); var atLeastOneChildIncluded = false; foreach (var filter in this.filters) { if (atLeastOneChildIncluded) { statement.Append(" AND "); } if (filter.BuildWhere(extent, mapping, statement, type, alias)) { atLeastOneChildIncluded = true; } } if (!root) { statement.Append(")"); } return atLeastOneChildIncluded; } return false; }
public Fragment( int fragmentId, IObjectType typeCondition, FragmentSpreadNode fragmentSpread, FragmentDefinitionNode fragmentDefinition, ISelectionSet selectionSet, bool internalFragment, SelectionIncludeCondition?includeCondition) { TypeCondition = typeCondition; SyntaxNode = fragmentDefinition; SelectionSet = selectionSet; Directives = fragmentSpread.Directives; IsInternal = internalFragment; IsConditional = includeCondition is not null; _fragmentId = fragmentId; _includeCondition = includeCondition; InclusionKind = internalFragment ? SelectionInclusionKind.Internal : SelectionInclusionKind.Always; if (IsConditional) { InclusionKind = internalFragment ? SelectionInclusionKind.InternalConditional : SelectionInclusionKind.Conditional; } }
/// <summary> /// Creates a procedure type with resolved arguments. /// </summary> /// <param name="baseTypeName">Name of the resolved base type.</param> /// <param name="baseType">The base type.</param> /// <param name="resolvedBaseType">The resolved base type.</param> /// <param name="overloadList">The list of resolved overloads.</param> /// <param name="resolvedTypeName">The type name upon return.</param> /// <param name="resolvedType">The type upon return.</param> public static void BuildType(ITypeName baseTypeName, IObjectType baseType, ICompiledTypeWithFeature resolvedBaseType, IList <ICommandOverloadType> overloadList, out ITypeName resolvedTypeName, out IProcedureType resolvedType) { IProcedureType ResolvedProcedureType = new ProcedureType(baseTypeName, baseType, resolvedBaseType, overloadList); resolvedTypeName = new TypeName(ResolvedProcedureType.TypeFriendlyName); resolvedType = ResolvedProcedureType; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.Include) { statement.Append("("); var atLeastOneChildIncluded = false; foreach (AllorsPredicateSql filter in this.filters) { if (atLeastOneChildIncluded) { statement.Append(" OR "); } if (filter.BuildWhere(extent, mapping, statement, type, alias)) { atLeastOneChildIncluded = true; } } statement.Append(")"); return atLeastOneChildIncluded; } return false; }
/// <summary> /// Retrieve the CMIS metadata of a document. /// </summary> /// <returns>a dictionary in which each key is a type id and each value is a couple indicating the mode ("readonly" or "ReadWrite") and the value itself.</returns> public static Dictionary <string, string[]> FetchMetadata(ICmisObject o, IObjectType typeDef) { Dictionary <string, string[]> metadata = new Dictionary <string, string[]>(); IList <IPropertyDefinition> propertyDefs = typeDef.PropertyDefinitions; // Get metadata. foreach (IProperty property in o.Properties) { // Mode string mode = "readonly"; foreach (IPropertyDefinition propertyDef in propertyDefs) { if (propertyDef.Id.Equals("cmis:name")) { Updatability updatability = propertyDef.Updatability; mode = updatability.ToString(); } } // Value if (property.IsMultiValued) { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValuesAsString }); } else { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValueAsString }); } } return(metadata); }
public AccessControlList(IObject obj, User user) { this.user = user; this.objectType = obj.Strategy.Class; this.databaseSession = this.user.Strategy.Session; this.accessControlledObject = (AccessControlledObject)obj; }
/// <summary> /// Retrieve the CMIS metadata of a document. /// </summary> /// <returns>a dictionary in which each key is a type id and each value is a couple indicating the mode ("readonly" or "ReadWrite") and the value itself.</returns> private Dictionary <string, string[]> FetchMetadata(IDocument document) { Dictionary <string, string[]> metadata = new Dictionary <string, string[]>(); IObjectType typeDef = session.GetTypeDefinition(document.ObjectType.Id /*"cmis:document" not Name FullName*/); // TODO cache IList <IPropertyDefinition> propertyDefs = typeDef.PropertyDefinitions; // Get metadata. foreach (IProperty property in document.Properties) { // Mode string mode = "readonly"; foreach (IPropertyDefinition propertyDef in propertyDefs) { if (propertyDef.Id.Equals("cmis:name")) { Updatability updatability = propertyDef.Updatability; mode = updatability.ToString(); } } // Value if (property.IsMultiValued) { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValuesAsString }); } else { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValueAsString }); } } return(metadata); }
// ---- asserts ---- public void AssertAreEqual(IObjectType expected, IObjectType actual) { if (expected == null && actual == null) { return; } Assert.NotNull(expected); Assert.NotNull(actual); Assert.NotNull(actual.Id); Assert.AreEqual(expected.Id, actual.Id); Assert.AreEqual(expected.IsBaseType, actual.IsBaseType); Assert.AreEqual(expected.BaseTypeId, actual.BaseTypeId); Assert.AreEqual(expected.DisplayName, actual.DisplayName); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.LocalName, actual.LocalName); Assert.AreEqual(expected.LocalNamespace, actual.LocalNamespace); Assert.AreEqual(expected.QueryName, actual.QueryName); Assert.AreEqual(expected.PropertyDefinitions.Count, actual.PropertyDefinitions.Count); foreach (IPropertyDefinition propDef in expected.PropertyDefinitions) { Assert.NotNull(propDef); Assert.NotNull(propDef.Id); IPropertyDefinition propDef2 = actual[propDef.Id]; AssertAreEqual(propDef, propDef2); } }
public ICachedObject GetOrCreateCachedObject(IObjectType concreteClass, long objectId, long localCacheId) { if (this.transientConcreteClasses != null && this.transientConcreteClasses.Contains(concreteClass)) { return(new CachedObject(localCacheId)); } CachedObject cachedObject; if (this.cachedObjectByObjectId.TryGetValue(objectId, out cachedObject)) { if (!cachedObject.LocalCacheVersion.Equals(localCacheId)) { cachedObject = new CachedObject(localCacheId); this.cachedObjectByObjectId[objectId] = cachedObject; } } else { cachedObject = new CachedObject(localCacheId); this.cachedObjectByObjectId[objectId] = cachedObject; } return(cachedObject); }
public PreparedSelection( IObjectType declaringType, IObjectField field, FieldNode selection, FieldDelegate resolverPipeline, NameString?responseName = null, IReadOnlyDictionary <NameString, PreparedArgument>?arguments = null, SelectionIncludeCondition?includeCondition = null, bool internalSelection = false) { DeclaringType = declaringType ?? throw new ArgumentNullException(nameof(declaringType)); Field = field ?? throw new ArgumentNullException(nameof(field)); Selection = selection ?? throw new ArgumentNullException(nameof(selection)); ResponseName = responseName ?? (selection.Alias is null ? selection.Name.Value : selection.Alias.Value); ResolverPipeline = resolverPipeline ?? throw new ArgumentNullException(nameof(resolverPipeline)); Arguments = arguments is null ? _emptyArguments : new PreparedArgumentMap(arguments); Selections = _emptySelections; InclusionKind = internalSelection ? SelectionInclusionKind.Internal : SelectionInclusionKind.Always; if (includeCondition is { })
internal RoleInstanceof(ExtentFiltered extent, IRoleType role, IObjectType instanceType, IObjectType[] instanceClasses) { extent.CheckRole(role); PredicateAssertions.ValidateRoleInstanceOf(role, instanceType); this.role = role; this.instanceClasses = instanceClasses; }
public bool ContainsConcreteClass(IComposite objectType, IObjectType concreteClass) { object concreteClassOrClasses; if (!this.concreteClassesByObjectType.TryGetValue(objectType, out concreteClassOrClasses)) { if (objectType.ExistExclusiveClass) { concreteClassOrClasses = objectType.ExclusiveClass; this.concreteClassesByObjectType[objectType] = concreteClassOrClasses; } else { concreteClassOrClasses = new HashSet <IObjectType>(objectType.Classes); this.concreteClassesByObjectType[objectType] = concreteClassOrClasses; } } if (concreteClassOrClasses is IObjectType) { return(concreteClass.Equals(concreteClassOrClasses)); } var concreteClasses = (HashSet <IObjectType>)concreteClassOrClasses; return(concreteClasses.Contains(concreteClass)); }
internal AllorsPredicateRoleInstanceofSql(AllorsExtentFilteredSql extent, IRoleType role, IObjectType instanceType, IClass[] instanceClasses) { extent.CheckRole(role); PredicateAssertions.ValidateRoleInstanceOf(role, instanceType); this.role = role; this.instanceClasses = instanceClasses; }
internal AllorsPredicateAssociationInstanceofSql(AllorsExtentFilteredSql extent, IAssociationType association, IObjectType instanceType, IClass[] instanceClasses) { extent.CheckAssociation(association); PredicateAssertions.ValidateAssociationInstanceof(association, instanceType); this.association = association; this.instanceClasses = instanceClasses; }
// objects public ICmisObject ConvertObject(IObjectData objectData, IOperationContext context) { if (objectData == null) { throw new ArgumentNullException("objectData"); } IObjectType type = GetTypeFromObjectData(objectData); switch (objectData.BaseTypeId) { case BaseTypeId.CmisDocument: return(new Document(session, type, objectData, context)); case BaseTypeId.CmisFolder: return(new Folder(session, type, objectData, context)); case BaseTypeId.CmisPolicy: return(new Policy(session, type, objectData, context)); case BaseTypeId.CmisRelationship: return(new Relationship(session, type, objectData, context)); default: throw new CmisRuntimeException("Unsupported type: " + objectData.BaseTypeId.ToString()); } }
/// <summary> /// Checks for errors before applying a rule. /// </summary> /// <param name="node">The node instance to check.</param> /// <param name="dataList">Optional data collected during inspection of sources.</param> /// <param name="data">Private data to give to Apply() upon return.</param> /// <returns>True if an error occured.</returns> public override bool CheckConsistency(IConstantFeature node, IDictionary <ISourceTemplate, object> dataList, out object data) { data = null; bool Success = true; IName EntityName = (IName)((IFeatureWithName)node).EntityName; IObjectType TypeToResolve = (IObjectType)node.EntityType; IClass EmbeddingClass = node.EmbeddingClass; if (TypeToResolve.ResolvedType.Item is IClassType AsClassType) { if (AsClassType.BaseClass.Cloneable == BaseNode.CloneableStatus.Single) { AddSourceError(new ErrorSingleTypeNotAllowed(node, EntityName.ValidText.Item)); Success = false; } } if (Success) { IScopeAttributeFeature NewEntity = ScopeAttributeFeature.CreateResultFeature(TypeToResolve, EmbeddingClass, node); data = NewEntity; } return(Success); }
internal bool AddWhere(IObjectType rootClass, string alias) { var useWhere = !this.Extent.ObjectType.ExistExclusiveClass; if (useWhere) { this.Append(" WHERE ( "); if (!this.Type.IsInterface) { this.Append(" " + alias + "." + Mapping.ColumnNameForClass + "=" + this.AddParameter(this.Type.Id)); } else { var first = true; foreach (var subClass in ((IInterface)this.Type).Subclasses) { if (first) { first = false; } else { this.Append(" OR "); } this.Append(" " + alias + "." + Mapping.ColumnNameForClass + "=" + this.AddParameter(subClass.Id)); } } this.Append(" ) "); } return(useWhere); }
public Fragment( IObjectType typeCondition, InlineFragmentNode inlineFragment, ISelectionSet selectionSet, bool internalFragment, SelectionIncludeCondition?includeCondition) { TypeCondition = typeCondition; SyntaxNode = inlineFragment; SelectionSet = selectionSet; Directives = inlineFragment.Directives; IsInternal = internalFragment; IsConditional = includeCondition is not null; _includeCondition = includeCondition; InclusionKind = internalFragment ? SelectionInclusionKind.Internal : SelectionInclusionKind.Always; if (IsConditional) { InclusionKind = internalFragment ? SelectionInclusionKind.InternalConditional : SelectionInclusionKind.Conditional; } }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(ITypedef node, object data) { IObjectType DefinedTypeItem = (IObjectType)node.DefinedType; ITypeName DefinedTypeName = DefinedTypeItem.ResolvedTypeName.Item; ICompiledType DefinedType = DefinedTypeItem.ResolvedType.Item; node.ResolvedDefinedTypeName.Item = DefinedTypeName; node.ResolvedDefinedType.Item = DefinedType; if (!DefinedType.OriginatingTypedef.IsAssigned) { DefinedType.OriginatingTypedef.Item = node; } IName EntityName = (IName)node.EntityName; IClass EmbeddingClass = node.EmbeddingClass; Debug.Assert(EntityName.ValidText.IsAssigned); string ValidText = EntityName.ValidText.Item; bool IsFound = FeatureName.TableContain(EmbeddingClass.LocalTypedefTable, ValidText, out IFeatureName Key, out ITypedefType ResolvedTypedefType); Debug.Assert(IsFound && ResolvedTypedefType != null); ResolvedTypedefType.ReferencedTypeName.Item = DefinedTypeName; ResolvedTypedefType.ReferencedType.Item = DefinedType; #if COVERAGE string TypeString = ResolvedTypedefType.ToString(); #endif }
/// <summary> /// Validates this instance. /// </summary> /// <param name="validationLog">The validation.</param> protected internal override void Validate(ValidationLog validationLog) { base.Validate(validationLog); if (this.Subtype != null && this.Supertype != null) { if (this.MetaPopulation.Inheritances.Count(inheritance => this.Subtype.Equals(inheritance.Subtype) && this.Supertype.Equals(inheritance.Supertype)) != 1) { var message = "name of " + this.ValidationName + " is already in use"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } IObjectType tempQualifier = this.Supertype; if (tempQualifier is IClass) { var message = this.ValidationName + " can not have a concrete superclass"; validationLog.AddError(message, this, ValidationKind.Hierarchy, "Inheritance.Supertype"); } } else { if (this.Supertype == null) { var message = this.ValidationName + " has a missing Supertype"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } else { var message = this.ValidationName + " has a missing Subtype"; validationLog.AddError(message, this, ValidationKind.Unique, "Inheritance.Supertype"); } } }
public IObjectId CreateDocumentFromSource(IObjectId source, IDictionary <string, object> properties, IObjectId folderId, VersioningState?versioningState, IList <IPolicy> policies, IList <IAce> addAces, IList <IAce> removeAces) { if (source == null || source.Id == null) { throw new ArgumentException("Source must be set!"); } // get the type of the source document IObjectType type = null; if (source is ICmisObject) { type = ((ICmisObject)source).ObjectType; } else { ICmisObject sourceObj = GetObject(source); type = sourceObj.ObjectType; } if (type.BaseTypeId != BaseTypeId.CmisDocument) { throw new ArgumentException("Source object must be a document!"); } string newId = Binding.GetObjectService().CreateDocumentFromSource(RepositoryId, source.Id, ObjectFactory.ConvertProperties(properties, type, (versioningState == VersioningState.CheckedOut ? CreateAndCheckoutUpdatability : CreateUpdatability)), (folderId == null ? null : folderId.Id), versioningState, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces), ObjectFactory.ConvertAces(removeAces), null); return(newId == null ? null : CreateObjectId(newId)); }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.instanceClasses.Length == 1) { statement.Append(" (" + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND "); statement.Append(" " + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[0].Id) + ")"); } else if (this.instanceClasses.Length > 1) { statement.Append(" ( "); for (int i = 0; i < this.instanceClasses.Length; i++) { statement.Append(" (" + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + " IS NOT NULL AND "); statement.Append(" " + statement.GetJoinName(this.role) + "." + Mapping.ColumnNameForType + "=" + statement.AddParameter(this.instanceClasses[i].Id) + ")"); if (i < this.instanceClasses.Length - 1) { statement.Append(" OR "); } } statement.Append(" ) "); } return this.Include; }
/// <summary> /// Gets the .Net <see cref="Type"/> given the Allors <see cref="IObjectType"/>. /// </summary> /// <param name="objectType">The Allors <see cref="IObjectType"/>.</param> /// <returns>The .Net <see cref="Type"/>.</returns> public Type GetTypeForObjectType(IObjectType objectType) { Type type; this.typeByObjectType.TryGetValue(objectType, out type); return(type); }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IPositionalTypeArgument node, object data) { IObjectType TypeToResolve = (IObjectType)node.Source; node.ResolvedSourceTypeName.Item = TypeToResolve.ResolvedTypeName.Item; node.ResolvedSourceType.Item = TypeToResolve.ResolvedType.Item; }
/// <summary> /// Checks for errors before applying a rule. /// </summary> /// <param name="node">The node instance to check.</param> /// <param name="dataList">Optional data collected during inspection of sources.</param> /// <param name="data">Private data to give to Apply() upon return.</param> /// <returns>True if an error occured.</returns> public override bool CheckConsistency(IEntityDeclaration node, IDictionary <ISourceTemplate, object> dataList, out object data) { bool Success = true; data = null; IName EntityName = (IName)node.EntityName; string ValidText = EntityName.ValidText.Item; IClass EmbeddingClass = node.EmbeddingClass; IObjectType FieldType = (IObjectType)node.EntityType; ITypeName ValidTypeName = FieldType.ResolvedTypeName.Item; ICompiledType ValidType = FieldType.ResolvedType.Item; IScopeAttributeFeature NewEntity; if (node.DefaultValue.IsAssigned) { Success = ScopeAttributeFeature.Create(node, ValidText, FieldType.ResolvedTypeName.Item, FieldType.ResolvedType.Item, (IExpression)node.DefaultValue.Item, ErrorList, out NewEntity); } else { NewEntity = ScopeAttributeFeature.Create(node, ValidText, FieldType.ResolvedTypeName.Item, FieldType.ResolvedType.Item); } if (Success) { data = NewEntity; } return(Success); }
public static IObjects GetObjects(this IObjectType objectType, ISession session) { var objectFactory = session.Database.ObjectFactory; var type = objectFactory.Assembly.GetType(objectFactory.Namespace + "." + objectType.PluralName); return((IObjects)Activator.CreateInstance(type, new object[] { session })); }
public IDictionary <string, IProperty> ConvertProperties(IObjectType objectType, IProperties properties) { if (objectType == null) { throw new ArgumentNullException("objectType"); } if (objectType.PropertyDefinitions == null) { throw new ArgumentException("Object type has no property defintions!"); } if (properties == null || properties.PropertyList == null) { throw new ArgumentException("Properties must be set!"); } // iterate through properties and convert them IDictionary <string, IProperty> result = new Dictionary <string, IProperty>(); foreach (IPropertyData property in properties.PropertyList) { // find property definition IProperty apiProperty = ConvertProperty(objectType, property); result[property.Id] = apiProperty; } return(result); }
/// <summary> /// Creates a function type with resolved arguments. /// </summary> /// <param name="baseTypeName">The type name of the resolved base type.</param> /// <param name="baseType">The base type.</param> /// <param name="resolvedBaseType">The resolved base type.</param> /// <param name="entityTypeName">The type name of the resolved result type.</param> /// <param name="entityType">The type of the resolved result type.</param> /// <param name="propertyKind">The type of the property.</param> /// <param name="getEnsureList">The list of ensure assertions for the getter.</param> /// <param name="getExceptionIdentifierList">The list of known exceptions thrown for the getter.</param> /// <param name="setRequireList">The list of require assertions for the setter.</param> /// <param name="setExceptionIdentifierList">The list of known exceptions thrown for the setter.</param> /// <param name="resolvedTypeName">The type name upon return.</param> /// <param name="resolvedType">The type upon return.</param> public static void BuildType(ITypeName baseTypeName, IObjectType baseType, ICompiledTypeWithFeature resolvedBaseType, ITypeName entityTypeName, ICompiledType entityType, BaseNode.UtilityType propertyKind, IList <IAssertion> getEnsureList, IList <IIdentifier> getExceptionIdentifierList, IList <IAssertion> setRequireList, IList <IIdentifier> setExceptionIdentifierList, out ITypeName resolvedTypeName, out ICompiledType resolvedType) { IPropertyType ResolvedPropertyType = new PropertyType(baseTypeName, baseType, resolvedBaseType, entityTypeName, entityType, propertyKind, getEnsureList, getExceptionIdentifierList, setRequireList, setExceptionIdentifierList); resolvedTypeName = new TypeName(ResolvedPropertyType.TypeFriendlyName); resolvedType = ResolvedPropertyType; }
/// <summary> /// Asserts that the <see cref="IObjectType"/> is compatible with /// <see cref="ICompositePredicate#AddInstanceof"/>. /// </summary> /// <param name="objectType">The object type.</param> public static void ValidateInstanceof(IObjectType objectType) { if (objectType is IUnit) { throw new ArgumentException("AddInstanceOf() can only be used with composite types."); } }
/// <summary> /// Applies the rule. /// </summary> /// <param name="node">The node instance to modify.</param> /// <param name="data">Private data from CheckConsistency().</param> public override void Apply(IIndexerType node, object data) { IClassType BaseType = ((Tuple <IClassType, ISealableList <IParameter> >)data).Item1; ISealableList <IParameter> ParameterTable = ((Tuple <IClassType, ISealableList <IParameter> >)data).Item2; IClass EmbeddingClass = node.EmbeddingClass; IObjectType BaseTypeItem = (IObjectType)node.BaseType; IObjectType EntityTypeItem = (IObjectType)node.EntityType; Debug.Assert(node.ParameterTable.Count == 0); node.ParameterTable.AddRange(ParameterTable); node.ParameterTable.Seal(); ITypeName BaseTypeName = BaseTypeItem.ResolvedTypeName.Item; ITypeName EntityTypeName = EntityTypeItem.ResolvedTypeName.Item; ICompiledType EntityType = EntityTypeItem.ResolvedType.Item; #if COVERAGE string TypeString = node.ToString(); Debug.Assert(!node.IsReference); Debug.Assert(node.IsValue); #endif IndexerType.ResolveType(EmbeddingClass.TypeTable, BaseTypeName, BaseType, EntityTypeName, EntityType, node.IndexerKind, node.IndexParameterList, node.ParameterEnd, node.GetRequireList, node.GetEnsureList, node.GetExceptionIdentifierList, node.SetRequireList, node.SetEnsureList, node.SetExceptionIdentifierList, out ITypeName ResolvedTypeName, out ICompiledType ResolvedType); node.ResolvedTypeName.Item = ResolvedTypeName; node.ResolvedType.Item = ResolvedType; }
internal virtual HashSet <Strategy> GetStrategiesForExtentIncludingDeleted(IObjectType type) { IObjectType[] concreteClasses; if (!this.concreteClassesByObjectType.TryGetValue(type, out concreteClasses)) { var sortedClassAndSubclassList = new List <IObjectType>(); if (type is IClass) { sortedClassAndSubclassList.Add(type); } if (type is IInterface) { foreach (var subClass in ((IInterface)type).Subclasses) { sortedClassAndSubclassList.Add(subClass); } } concreteClasses = sortedClassAndSubclassList.ToArray(); this.concreteClassesByObjectType[type] = concreteClasses; } switch (concreteClasses.Length) { case 0: return(EmptyStrategies); case 1: { var objectType = concreteClasses[0]; HashSet <Strategy> strategies; if (this.strategiesByObjectType.TryGetValue(objectType, out strategies)) { return(strategies); } return(EmptyStrategies); } default: { var strategies = new HashSet <Strategy>(); foreach (var objectType in concreteClasses) { HashSet <Strategy> objectTypeStrategies; if (this.strategiesByObjectType.TryGetValue(objectType, out objectTypeStrategies)) { strategies.UnionWith(objectTypeStrategies); } } return(strategies); } } }
private bool CheckAssignmentTypeArgumentsValidity(IGenericType node, IClass baseClass, ISealableDictionary <string, ICompiledType> resolvedTable, ISealableDictionary <string, IObjectType> locationTable) { bool Result = true; List <string> ValidNameList = new List <string>(); foreach (IGeneric Generic in baseClass.GenericList) { IName EntityName = (IName)Generic.EntityName; string GenericName = EntityName.ValidText.Item; ValidNameList.Add(GenericName); } foreach (IAssignmentTypeArgument Item in node.TypeArgumentList) { IIdentifier ParameterIdentifier = (IIdentifier)Item.ParameterIdentifier; string GenericName = ParameterIdentifier.ValidText.Item; // This is checked in a separate rule. Debug.Assert(!resolvedTable.ContainsKey(GenericName)); if (!ValidNameList.Contains(GenericName)) { AddSourceError(new ErrorUnknownIdentifier(ParameterIdentifier, GenericName)); Result = false; } ICompiledType ActualArgumentType = Item.ResolvedSourceType.Item; resolvedTable.Add(GenericName, ActualArgumentType); locationTable.Add(GenericName, (IObjectType)Item.Source); } foreach (IGeneric Generic in baseClass.GenericList) { IName EntityName = (IName)Generic.EntityName; string GenericName = EntityName.ValidText.Item; if (!resolvedTable.ContainsKey(GenericName)) { if (Generic.DefaultValue.IsAssigned) { IObjectType DefaultValue = (IObjectType)Generic.DefaultValue.Item; Debug.Assert(DefaultValue.ResolvedType.IsAssigned); ICompiledType ActualArgumentType = DefaultValue.ResolvedType.Item; resolvedTable.Add(GenericName, ActualArgumentType); locationTable.Add(GenericName, null); } else { AddSourceError(new ErrorMissingTypeArgument(node, GenericName)); Result = false; } } } return(Result); }
public void Clear() { IType = IObjectType.I_Matrix; Name = ""; empty = true; bracketDepth = 0; insideString = new StringBuilder(); }
public ISelectionSet GetSelectionSet( SelectionSetNode selectionSet, IObjectType typeContext) { return(_selectionSets.TryGetValue(selectionSet, out SelectionVariants? variants) ? variants.GetSelectionSet(typeContext) : SelectionSet.Empty); }
internal AssociationInstanceOf(ExtentFiltered extent, IAssociationType associationType, IObjectType instanceObjectType) { extent.CheckForAssociationType(associationType); PredicateAssertions.ValidateAssociationInstanceof(associationType, instanceObjectType); this.associationType = associationType; this.objectType = instanceObjectType; }
public IObjectType GetBaseType() { if (IsBaseType) { return null; } if (baseType != null) { return baseType; } baseType = session.GetTypeDefinition(objectType.BaseTypeId.GetCmisValue()); return baseType; }
public IObjectType GetParentType() { if (parentType != null) { return parentType; } if (objectType.ParentTypeId == null) { return null; } parentType = session.GetTypeDefinition(objectType.ParentTypeId); return parentType; }
public static object Build(ISession session, IObjectType objectType) { if (objectType.IsUnit) { var unit = (Unit)objectType; var unitTypeTag = unit.UnitTag; switch (unitTypeTag) { case UnitTags.AllorsString: return string.Empty; case UnitTags.AllorsInteger: return 0; case UnitTags.AllorsDecimal: return 0m; case UnitTags.AllorsFloat: return 0d; case UnitTags.AllorsBoolean: return false; case UnitTags.AllorsBinary: return new byte[0]; case UnitTags.AllorsUnique: return Guid.NewGuid(); default: throw new ArgumentException("Unknown Unit ObjectType: " + unitTypeTag); } } Type builderType; if (!BuilderTypeByObjectTypeId.TryGetValue(objectType, out builderType)) { var builderTypeName = "Allors.Domain." + objectType.Name + "Builder"; builderType = Type.GetType(builderTypeName, false); if (builderType != null) { BuilderTypeByObjectTypeId[objectType] = builderType; } } if (builderType != null) { object[] parameters = { session }; var builder = (IObjectBuilder)Activator.CreateInstance(builderType, parameters); return builder.DefaultBuild(); } return session.Create((Class)objectType); }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append("\n"); statement.Append("EXISTS(\n"); statement.Append("SELECT " + Mapping.ColumnNameForObject + "\n"); statement.Append("FROM " + mapping.GetTableName(this.role) + "\n"); statement.Append("WHERE " + Mapping.ColumnNameForAssociation + "=" + alias + "." + Mapping.ColumnNameForObject + "\n"); statement.Append("AND " + Mapping.ColumnNameForRole + "=" + this.allorsObject.Strategy.ObjectId + "\n"); statement.Append(")\n"); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { AllorsExtentStatementSql inStatement = statement.CreateChild(inExtent, association); inStatement.UseRole(association.RoleType); statement.Append(" (" + association.SingularFullName + "_A." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + association.SingularFullName + "_A." + Mapping.ColumnNameForRole + " IN (\n"); inExtent.BuildSql(inStatement); statement.Append(" ))\n"); return Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { var inStatement = statement.CreateChild(this.inExtent, this.role); inStatement.UseAssociation(this.role.AssociationType); statement.Append(" (" + this.role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularFullName + "_R." + Mapping.ColumnNameForAssociation + " IN ("); this.inExtent.BuildSql(inStatement); statement.Append(" ))"); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { var inStatement = new StringBuilder("0"); foreach (var inObject in this.enumerable) { inStatement.Append(","); inStatement.Append(inObject.Id); } statement.Append(" (" + this.role.SingularPropertyName + "_R." + Mapping.ColumnNameForRole + " IS NOT NULL AND "); statement.Append(" " + this.role.SingularPropertyName + "_R." + Mapping.ColumnNameForAssociation + " IN ("); statement.Append(inStatement.ToString()); statement.Append(" ))"); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " BETWEEN " + first.SingularFullName + "_R." + Mapping.ColumnNameForRole + " AND " + second.SingularFullName + "_R." + Mapping.ColumnNameForRole + " "); return Include; }
protected void Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) { if (session == null) { throw new ArgumentNullException("session"); } if (objectType == null) { throw new ArgumentNullException("objectType"); } if (objectType.PropertyDefinitions == null || objectType.PropertyDefinitions.Count < 9) { // there must be at least the 9 standard properties that all objects have throw new ArgumentException("Object type must have property defintions!"); } this.Session = session; this.objectType = objectType; this.extensions = new Dictionary<ExtensionLevel, IList<ICmisExtensionElement>>(); this.CreationContext = new OperationContext(context); this.RefreshTimestamp = DateTime.UtcNow; IObjectFactory of = Session.ObjectFactory; if (objectData != null) { // handle properties if (objectData.Properties != null) { properties = of.ConvertProperties(objectType, objectData.Properties); extensions[ExtensionLevel.Properties] = objectData.Properties.Extensions; } // handle allowable actions if (objectData.AllowableActions != null) { allowableActions = objectData.AllowableActions; extensions[ExtensionLevel.AllowableActions] = objectData.AllowableActions.Extensions; } // handle renditions if (objectData.Renditions != null) { renditions = new List<IRendition>(); foreach (IRenditionData rd in objectData.Renditions) { renditions.Add(of.ConvertRendition(Id, rd)); } } // handle ACL if (objectData.Acl != null) { acl = objectData.Acl; extensions[ExtensionLevel.Acl] = objectData.Acl.Extensions; } // handle policies if (objectData.PolicyIds != null && objectData.PolicyIds.PolicyIds != null) { policies = new List<IPolicy>(); foreach (string pid in objectData.PolicyIds.PolicyIds) { IPolicy policy = Session.GetObject(Session.CreateObjectId(pid)) as IPolicy; if (policy != null) { policies.Add(policy); } } extensions[ExtensionLevel.Policies] = objectData.PolicyIds.Extensions; } // handle relationships if (objectData.Relationships != null) { relationships = new List<IRelationship>(); foreach (IObjectData rod in objectData.Relationships) { IRelationship relationship = of.ConvertObject(rod, CreationContext) as IRelationship; if (relationship != null) { relationships.Add(relationship); } } } extensions[ExtensionLevel.Object] = objectData.Extensions; } }
public Document(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) { Initialize(session, objectType, objectData, context); }
public Relationship(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) { Initialize(session, objectType, objectData, context); }
/// <summary> /// Retrieve the CMIS metadata of a document. /// </summary> /// <returns>a dictionary in which each key is a type id and each value is a couple indicating the mode ("readonly" or "ReadWrite") and the value itself.</returns> public static Dictionary<string, string[]> FetchMetadata(ICmisObject o, IObjectType typeDef) { Dictionary<string, string[]> metadata = new Dictionary<string, string[]>(); IList<IPropertyDefinition> propertyDefs = typeDef.PropertyDefinitions; // Get metadata. foreach (IProperty property in o.Properties) { // Mode string mode = "readonly"; foreach (IPropertyDefinition propertyDef in propertyDefs) { if (propertyDef.Id.Equals("cmis:name")) { Updatability updatability = propertyDef.Updatability; mode = updatability.ToString(); } } // Value if (property.IsMultiValued) { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValuesAsString }); } else { metadata.Add(property.Id, new string[] { property.DisplayName, mode, property.ValueAsString }); } } return metadata; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + this.role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " > " + this.greaterThanRole.SingularFullName + "_R." + Mapping.ColumnNameForRole); return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { if (this.Include) { statement.Append(" NOT ("); this.filter.BuildWhere(extent, mapping, statement, type, alias); statement.Append(")"); } return this.Include; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + this.association.SingularFullName + "_A." + Mapping.ColumnNameForAssociation + " IS NOT NULL"); return this.Include; }
public IItemEnumerable<IRelationship> GetRelationships(IObjectId objectId, bool includeSubRelationshipTypes, RelationshipDirection? relationshipDirection, IObjectType type, IOperationContext context) { if (objectId == null || objectId.Id == null) { throw new ArgumentException("Invalid object id!"); } string id = objectId.Id; string typeId = (type == null ? null : type.Id); IRelationshipService service = Binding.GetRelationshipService(); IOperationContext ctxt = new OperationContext(context); PageFetcher<IRelationship>.FetchPage fetchPageDelegate = delegate(long maxNumItems, long skipCount) { // fetch the relationships IObjectList relList = service.GetObjectRelationships(RepositoryId, id, includeSubRelationshipTypes, relationshipDirection, typeId, ctxt.FilterString, ctxt.IncludeAllowableActions, maxNumItems, skipCount, null); // convert relationship objects IList<IRelationship> page = new List<IRelationship>(); if (relList.Objects != null) { foreach (IObjectData rod in relList.Objects) { IRelationship relationship = GetObject(CreateObjectId(rod.Id), ctxt) as IRelationship; if (relationship == null) { throw new CmisRuntimeException("Repository returned an object that is not a relationship!"); } page.Add(relationship); } } return new PageFetcher<IRelationship>.Page<IRelationship>(page, relList.NumItems, relList.HasMoreItems); }; return new CollectionEnumerable<IRelationship>(new PageFetcher<IRelationship>(DefaultContext.MaxItemsPerPage, fetchPageDelegate)); }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" " + role.SingularFullName + "_R." + Mapping.ColumnNameForRole + " LIKE " + statement.AddParameter(this.str)); return this.Include; }
public IObject() { iType = IObjectType.I_Null; }
public IObject(IObjectType type) { iType = type; }
internal override bool BuildWhere(AllorsExtentFilteredSql extent, Mapping mapping, AllorsExtentStatementSql statement, IObjectType type, string alias) { statement.Append(" (" + alias + "." + Mapping.ColumnNameForObject + "=" + statement.AddParameter(obj) + ") "); return Include; }
private static Unit GetAllorsString(IObjectType objectType) { return (Unit)objectType.MetaPopulation.Find(UnitIds.StringId); }
internal static IObjectType[] GetConcreteSubClasses(IObjectType type) { if (type.IsInterface) { return ((IInterface)type).Subclasses.ToArray(); } var concreteSubclasses = new IObjectType[1]; concreteSubclasses[0] = type; return concreteSubclasses; }